SA-MP Forums Archive
bug save mysql [+4 rep] - 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: bug save mysql [+4 rep] (/showthread.php?tid=510095)



bug save mysql [+4 rep] - DarkZeroX - 29.04.2014

Hello!

My save account bug :/

Код:
public SaveAccount(playerid)
{
    if(Connected[playerid] == 0)
	     return 1;
    new string[1024], string1[1024];
    format(string1, sizeof(string1), "UPDATE comptes SET p_mdp = %s, p_email = %s, p_code = %d, p_ip = %s, p_warn = %d, p_jail = %d",p_info[playerid][p_mdp],
    p_info[playerid][p_email],p_info[playerid][p_code],p_info[playerid][p_ip],p_info[playerid][p_warn],p_info[playerid][p_jail]);
    strcat(string, string1);

    format(string1, sizeof(string1), "p_ban = %d, p_skin = %d, p_age = %d, p_origine = %d, p_telephone",p_info[playerid][p_ban],
    p_info[playerid][p_ban],p_info[playerid][p_skin],p_info[playerid][p_age],p_info[playerid][p_origine],p_info[playerid][p_telephone]);
    strcat(string, string1);

    format(string1, sizeof(string1), "p_credits = %f, p_admin = %d, p_vip = %d, p_sac = %d, p_weed = %d, p_canabis = %d",p_info[playerid][p_credits],
    p_info[playerid][p_admin],p_info[playerid][p_vip],p_info[playerid][p_sac],p_info[playerid][p_weed],p_info[playerid][p_canabis]);
    strcat(string, string1);

    format(string1, sizeof(string1), "p_graine = %d, p_arme1 = %d, p_arme2 = %d, p_arme_vip1 = %d, p_arme_vip2 = %d, p_arme_vip3 = %d",p_info[playerid][p_graine],
    p_info[playerid][p_arme1],p_info[playerid][p_arme2],p_info[playerid][p_arme_vip1],p_info[playerid][p_arme_vip2],p_info[playerid][p_arme_vip3]);
    strcat(string, string1);

    format(string1, sizeof(string1), "p_faction = %d, p_rang = %d, p_maison = %d, p_commerce = %d, p_crash_x = %f, p_crash_y = %f, p_crash_z = %f",p_info[playerid][p_faction],
    p_info[playerid][p_rang],p_info[playerid][p_maison],p_info[playerid][p_commerce],p_info[playerid][p_crash_x],p_info[playerid][p_crash_y],p_info[playerid][p_crash_z]);
    strcat(string, string1);

    format(string, sizeof(string1), "p_crash_int = %d, p_crash_wv = %d, p_rename = %d, p_annuaire = %d, p_baillon = %d, p_jerrican = %d",p_info[playerid][p_crash_int],
    p_info[playerid][p_crash_wv],p_info[playerid][p_rename],p_info[playerid][p_annuaire],p_info[playerid][p_baillon],p_info[playerid][p_jerrican]);
    strcat(string, string1);

    format(string, sizeof(string1), "p_permis_moto = %d, p_permis_pmoto = %d, p_permis_avion = %d, p_permis_car = %d, p_permis_pcar = %d, p_permis_arme",p_info[playerid][p_permis_moto],
    p_info[playerid][p_permis_pmoto],p_info[playerid][p_permis_avion],p_info[playerid][p_permis_car],p_info[playerid][p_permis_pcar],p_info[playerid][p_permis_arme]);
    strcat(string, string1);

    format(string, sizeof(string1), "p_temps_travaille = %d, p_tuto = %d, p_casquette = %d, p_bandana = %d, p_lunette = %d, p_sante = %d",p_info[playerid][p_temps_travaille],
    p_info[playerid][p_tuto],p_info[playerid][p_casquette],p_info[playerid][p_bandana],p_info[playerid][p_lunette],p_info[playerid][p_sante]);
    strcat(string, string1);

    format(string, sizeof(string1), "p_armure = %d, p_cagoule = %d, p_cigarettes = %d, p_tabac = %d, p_feuilles = %d, p_combat = %d, p_marche = %d, p_compte = %d WHERE p_id = %d",p_info[playerid][p_armure],
    p_info[playerid][p_cagoule],p_info[playerid][p_cigarettes],p_info[playerid][p_tabac],p_info[playerid][p_feuilles],p_info[playerid][p_combat],p_info[playerid][p_marche],p_info[playerid][p_compte],p_info[playerid][p_id]);
    strcat(string, string1);
  
    mysql_function_query(mysql, string, true, "", "");
    return 1;
} 

Passing query p_armure = 10, p_cagoule = 0, p_cigarettes = 0, p_tabac = 0, p_feuilles = 0, p_combat = 0, p_marche = 0, p_compte = 0 WHERE p_id = 1p_faction = 1, p_rang = 2, p_maison = 0, p_commerce = 0, p_crash_x = 0.000000, p_crash_y = 0.000000, p_crash_z = 0.000000 | 
CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()



Re: bug save mysql [+4 rep] - arakuta - 29.04.2014

Please #define bug to us.

Debug with OnQueryError please.


Re: bug save mysql [+4 rep] - GeasyW - 29.04.2014

Check this tutorial yo (:
https://sampforum.blast.hk/showthread.php?tid=234691


Re: bug save mysql [+4 rep] - DarkZeroX - 29.04.2014

Quote:
Originally Posted by arakuta
Посмотреть сообщение
Please #define bug to us.

Debug with OnQueryError please.
Give me callback OnQueryError please (no english sorry :/)


Re: bug save mysql [+4 rep] - iZN - 29.04.2014

pawn Код:
public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
{
    printf("[OnQueryError] Error ID: %d", errorid);
    printf("[OnQueryError] Error: %s", error);
    printf("[OnQueryError] Callback: %s", callback);
    printf("[OnQueryError] Query: %s", query);
    printf("[OnQueryError] Connection handle: %d", connectionHandle);
}
I found the issue, you don't have , at the end on every formatted string.

PHP код:
UPDATE comptes SET p_mdp = %sp_email = %sp_code = %dp_ip = %sp_warn = %dp_jail = %d



Re: bug save mysql [+4 rep] - DarkZeroX - 29.04.2014

Код:
[OnQueryError] Error ID: 1064
[OnQueryError] Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p_armure = 10, p_cagoule = 0, p_cigarettes = 0, p_tabac = 0, p_feuilles = 0, p_c' at line 1
[OnQueryError] Callback: 
[OnQueryError] Query: p_armure = 10, p_cagoule = 0, p_cigarettes = 0, p_tabac = 0, p_feuilles = 0, p_combat = 0, p_marche = 0, p_compte = 0 WHERE p_id = 1p_faction = 0, p_rang = 0, p_maison = 0, p_commerce = 0, p_crash_x = 0.000000, p_crash_y = 0.000000, p_crash_z = 0.000000
 [OnQueryError] Connection handle: 1



Re: bug save mysql [+4 rep] - Guest4390857394857 - 29.04.2014

Change all ℅s to '℅s'

I mean add ' '
With single quotes,
This should reduce your error in query,
Your query is too big omg,


Re: bug save mysql [+4 rep] - [MWR]Blood - 29.04.2014

Looks like you gotta use ` backticks, as well as single quotes.
Example:
Код:
`p_mdp` = '%s'



Re: bug save mysql [+4 rep] - iZN - 29.04.2014

Quote:
Originally Posted by DarkZeroX
Посмотреть сообщение
Код:
[OnQueryError] Error ID: 1064
[OnQueryError] Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'p_armure = 10, p_cagoule = 0, p_cigarettes = 0, p_tabac = 0, p_feuilles = 0, p_c' at line 1
[OnQueryError] Callback: 
[OnQueryError] Query: p_armure = 10, p_cagoule = 0, p_cigarettes = 0, p_tabac = 0, p_feuilles = 0, p_combat = 0, p_marche = 0, p_compte = 0 WHERE p_id = 1p_faction = 0, p_rang = 0, p_maison = 0, p_commerce = 0, p_crash_x = 0.000000, p_crash_y = 0.000000, p_crash_z = 0.000000
 [OnQueryError] Connection handle: 1
Your query is confusing me. There is something wrong while strcat'ing them. Try to debug those strings through printf().

@Above posters ShivRp and [MWR]Blood:

You don't really need to add those ' ' or ` `, simple query works fine too. Usually scripters make them to look fancy, but it is wastage of time anyway. Although ' ' needs to be used only for strings, it is still needed. Do like this '%s' to every string specifier.

@Macronix: That won't work because the formatted string cannot be that longer, and it will give silly errors. You need to strcat them if they're long. This doesn't applies for the patched compiler by Zeex/xeeZ.


Re: bug save mysql [+4 rep] - [MWR]Blood - 29.04.2014

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
Looks like you gotta use ` backticks, as well as single quotes.
Example:
Код:
`p_mdp` = '%s'
You gotta do like this everywhere!