SA-MP Forums Archive
In need of further assistance please (SQL) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: In need of further assistance please (SQL) (/showthread.php?tid=340191)



In need of further assistance please (SQL) - Slix_ - 06.05.2012

My code is:
pawn Код:
if (dialogid == 45)
    {
        if (IsPlayerConnected(playerid))
        {
            if(response)
            {
                if(!IsNumeric(inputtext))
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] Order number (ID) should be a numerical value.");
                    return 1;
                }
                format(string, sizeof(string), "SELECT * FROM `order_product` WHERE order_id = '%d'", strval(inputtext));
                mysql_query(string);
                mysql_store_result();
                if(mysql_num_rows() > 0)
                {
                    new array[1064];
                    mysql_fetch_row(array);
                   
                    new orderproductid, orderid, productid, name[64], model[16], quantity, Float:price, Float:total, Float:tax, reward;

                    sscanf(array, "iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
                    SetPVarInt(playerid, "orderid", orderid);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "[ERROR] That order number (ID) does not exist.");
                }
                mysql_free_result();
            }
        }
    }
I am positive that the table order_product exists since I have created it manually by myself (confirmed it 3 times), and I also confirm that row order_id exists, yes, please don't ask these questions. Now, I am here to tell you that even if I type a valid order id, it returns with:

pawn Код:
SendClientMessage(playerid, COLOR_GREY, "[ERROR] That order number (ID) does not exist.");
Which explains that the database is returning with 0 rows, which is quiet impossible unless it is really unvalid order id, but I am positive it is a valid order id, can you please help me out with this?

Thanks for reading,
and thanks for caring.


Re: In need of further assistance please (SQL) - telmo_ferreira - 06.05.2012

show the mysql_log


Re: In need of further assistance please (SQL) - [MG]Dimi - 06.05.2012

Shouldn't
pawn Код:
sscanf(array, "iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
be
pawn Код:
sscanf(array, "p<|>iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
?


Re: In need of further assistance please (SQL) - Slix_ - 06.05.2012

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
Shouldn't
pawn Код:
sscanf(array, "iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
be
pawn Код:
sscanf(array, "p<|>iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
?
Yes, thanks for helping.

Quote:
Originally Posted by telmo_ferreira
Посмотреть сообщение
show the mysql_log
Problem solved - looking deeply at the mysql_log and found out what's wrong, thanks for letting me read it.


Re: In need of further assistance please (SQL) - Slix_ - 06.05.2012

Ok, the dialog begun to open for only valid order numbers I input, my problem is now:
- All outputs are "0" (no quotes), which isn't what I'm looking for.

Even though if I check mysql_log, I see the system obtaining the correct information (no 0 values), but the server is outputting it "0" - any idea on how to solve this? Thanks in advance.