PDA

View Full Version : In need of further assistance please (SQL)


Slix_
06/05/2012, 10:23 AM
My code is:

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:


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.

telmo_ferreira
06/05/2012, 10:33 AM
show the mysql_log

[MG]Dimi
06/05/2012, 10:39 AM
Shouldn't
sscanf(array, "iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
be
sscanf(array, "p<|>iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);

?

Slix_
06/05/2012, 11:22 AM
Dimi;1844785']Shouldn't
sscanf(array, "iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);
be
sscanf(array, "p<|>iiis[64]s[64]ifffi", orderproductid, orderid, productid, name, model, quantity, price, total, tax, reward);

?
Yes, thanks for helping.

show the mysql_log

Problem solved - looking deeply at the mysql_log and found out what's wrong, thanks for letting me read it.

Slix_
06/05/2012, 12:30 PM
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.