Possibly messed up MySQL Query, Won't display results. -
Dokins - 12.03.2014
pawn Код:
else if(dialogid == DIALOG_MDCPERSON)
{
printf("CALLED DIALOG_MDCPERSON");
if(response == 0)
{
ShowPlayerDialog(playerid, DIALOG_MDCMAIN, DIALOG_STYLE_LIST, "Mobile Data Computer", "Person Check\nVehicle Check\nBOLOS\nEmergency Calls\n", "Select", "Exit");
}
if(response == 1)
{
new escape[28], query[64];
mysql_real_escape_string(inputtext, escape);
format(query, sizeof(query), "SELECT `id` FROM `accounts` WHERE `PlayerName` = '%s' LIMIT 1", escape);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() > 0)
{
new string[256], second[64];
new id = mysql_fetch_int();
format(string, sizeof(string), "Full Name: {FF0000}%s\n", inputtext);
strcat(string, second);
HouseOwned[id] = MySQL_GetValue(id, "HouseOwned", "accounts");
if(HouseOwned[id] > 0)
{
format(second, sizeof(second), "Address: {FF0000}%s",HouseName[id]);
strcat(string, second);
}
if(HouseOwned[id] < 1)
{
format(second, sizeof(second), "Address: {FF0000}No Known Address.");
strcat(string, second);
}
Cellphone[id] = MySQL_GetValue(id, "Cellphone", "accounts");
Number[id] = MySQL_GetValue(id, "Number", "accounts");
if(Cellphone[id] > 0)
{
format(second, sizeof(second), "Contact Number: {FF0000}%d", Number[id]);
strcat(string, second);
}
if(Cellphone[id] < 1)
{
format(second, sizeof(second), "Contact Number: {FF0000}No Known Contact Number.", Number[id]);
strcat(string, second);
}
ShowPlayerDialog(playerid,DIALOG_SHOWPERSON,DIALOG_STYLE_MSGBOX,"Person Search Results", string,"Close","");
}
if(mysql_num_rows() < 1)
{
SendClientMessage(playerid, COLOUR_GREY, "Person Search Failed. Not Found.");
}
}
}
It doesn't display either result. I'm not entirely sure why, could someone assist me please?
Re: Possibly messed up MySQL Query, Won't display results. -
AceFlyer - 12.03.2014
pawn Код:
SELECT `id` FROM `accounts` WHERE `PlayerName` = '%s' LIMIT 1
i think its because you are selecting only the id from the table so what would be retrieved from the database would only be the id
Re: Possibly messed up MySQL Query, Won't display results. -
Dokins - 12.03.2014
Yes, but I only need the ID to retrieve the other data.
Re: Possibly messed up MySQL Query, Won't display results. -
PowerPC603 - 12.03.2014
If you only fetch the ID, MySQL will only return the ID, nothing else.
What does MySQL_GetValue do?
Re: Possibly messed up MySQL Query, Won't display results. -
Vince - 12.03.2014
Don't send more queries than absolutely necessary. This is good practice. All secondary data is fetched from the same table, so I don't see why you wouldn't write it all in a single query.
Original question: what plugin (and version thereof) are you using? Furthermore, to debug the code add a print statment in each if-construct.
Re: Possibly messed up MySQL Query, Won't display results. -
Dokins - 12.03.2014
It gets the field with the ID value I retrieved from the Player Name.
I wasn't actually sure how to put it into a single statement and be able to retrieve each part individually?
I've not recently checked the plugin, It's been a while, I'm sure its one of the latest. All other query's work.
Re: Possibly messed up MySQL Query, Won't display results. -
Dokins - 12.03.2014
Still having issues.