mysql insert
#1

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' 
Reply
#2

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);
Reply
#3

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.
Reply
#4

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;

Reply
#5

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

What is the print printing on the console?
Reply
#6

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
Reply
#7

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
Reply
#8

anyone?
Reply
#9

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.
Reply
#10

thanks, working
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)