SA-MP Forums Archive
mysql insert - 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: mysql insert (/showthread.php?tid=512928)



mysql insert - n00el - 13.05.2014

hello. how i can fix this?

PHP код:
stock AddLabelToFile(text[], Float:xFloat:yFloat:zFloat:distancewv)
{
    new
        
EscString[128];
    
mysql_real_escape_string(textEscString);
    
format(querysizeof(query), "INSERT INTO `3dtextlabel` (text, x, y, z, distance, wv) VALUES(%s, %f, %f, '%f', '%f' '%i')",EscStringxzydistancewv);
    
mysql_query(sqldbquery);
    
mysql_free_result();
    return 
1;

bug:
PHP код:
[16:43:40] [DEBUGmysql_query connection1query"INSERT INTO `3dtextlabel` (text, x, y, z, distance, wv) VALUES(a"use_cachetrue
[16:43:40] [DEBUGCMySQLQuery::Execute starting query execution
[16:43:40] [ERRORCMySQLQuery::Execute - (error #1054) Unknown column 'asd' in 'field list' 



Re: mysql insert - Luis- - 13.05.2014

pawn Код:
format(query, sizeof(query), "INSERT INTO `3dtextlabel` (text, x, y, z, distance, wv) VALUES('%s', %f, %f, %f, %f, %i)",EscString, x, z, y, distance, wv);



Re: mysql insert - Vince - 13.05.2014

You need to wrap texts in quotes otherwise MySQL will interpret the value as a column name. You do not need to wrap in other values in quotes. While this may still work it will force the server to do an implicit conversion from a string (e.g. '42') to its type (e.g. 42).

Edit: ^ Like that.


Re: mysql insert - n00el - 13.05.2014

ohh really.. thank!
and the load?
PHP код:
stock Load3DTextLabels()
{
    new
        
Str[100],
        
text[128],
        
Float:x,
        
Float:y,
        
Float:z,
        
Float:tavolsag,
        
wv,
        
total;
        
      
format(querysizeof(query), "SELECT * FROM `3dtextlabel`");
    
mysql_query(sqldbquery);
    
mysql_store_result();
    if(
mysql_num_rows() > 0)
    {
        while(
mysql_fetch_row(Str))
        {
            
sscanf(Str"p<|>s[128]ffffi"textxyztavolsagwv);
            
Create3DTextLabel(text0xFF0606FFxyztavolsagwv1);
            
total++;
            
printf("debug: %s %f %f %f %f i",textxyztavolsagwv);
        }
    }
    
mysql_free_result();
    
printf("%i textlabel betцltve!",total);
    return 
1;




Re: mysql insert - Luis- - 13.05.2014

Yeah, I should of explained it, thanks Vince :P

What is the print printing on the console?


Re: mysql insert - n00el - 13.05.2014

PHP код:
[16:57:25debug1 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug3 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug4 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug5 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug6 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug7 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug8 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug9 0.000000 0.000000 0.000000 0.000000 0
[16:57:25debug10 0.000000 0.000000 0.000000 0.000000 0
[16:57:259 textlabel betцltve



Re: mysql insert - n00el - 13.05.2014

tha save is ok, in my mysql:
PHP код:
3 RR04-01 -41.549 19.516 1169.14 10 0 
but its not loaded.
i think its not good (sscanf(Str, "p<|>s[128]ffffi", text, x, y, z, tavolsag, wv) but i dont know what is the error


Re: mysql insert - n00el - 13.05.2014

anyone?


Re: mysql insert - Madd92 - 13.05.2014

Quote:
Originally Posted by n00el
Посмотреть сообщение
pawn Код:
sscanf(Str, "p<|>s[128]ffffi", text, x, y, z, tavolsag, wv);
Why do you use the p<|>? I don't really get it, I didn't see delimiters before when you saved the data.


Re: mysql insert - n00el - 13.05.2014

thanks, working