Error in SQL syntax "string"
#1

Hello.
my system doesn't properly insert the string, and i have no idea why.
Could you maybe take a look at it?
PHP код:
forward onPlayerCarLoad(playerid);
public 
onPlayerCarLoad(playerid)
{
new 
num_fields,num_rows;
new 
string[420],temp_carowner[35],string2[420],temp_plate[50];
cache_get_data(num_rows,num_fields,dbhandle);
if(!
num_rows)return 1;
 for(new 
i=0i<num_rowsi++)
 {
  
cInfo[i][db_id]=cache_get_field_content_int(i,"id",dbhandle);
  new 
id=cInfo[id][db_id];
  
cInfo[id][carmodelid]=cache_get_field_content_int(i,"model",dbhandle);
  
cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
  
cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
  
cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
  
cInfo[id][c_r]=cache_get_field_content_float(i,"a",dbhandle);
  
cInfo[id][c_color1]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_color2]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_respawntime]=cache_get_field_content_int(i,"autorespawn",dbhandle);
  
cache_get_field_content(i"owner"temp_carowner);
format(string,sizeof(string),"%s",temp_carowner);
myStrcpy(cInfo[id][carowner], string);
CreateVehicle(cInfo[id][carmodelid],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][c_color1],cInfo[id][c_color2],cInfo[id][c_respawntime]);
cache_get_field_content(i"plate"temp_plate);
format(string2,sizeof(string2),"%s",temp_plate);
myStrcpy(cInfo[id][plate], string2);
SetVehicleNumberPlate(id,string2);
cInfo[id][cnitro]=cache_get_field_content_int(i,"nitro",dbhandle);
AddVehicleComponent(id,cInfo[id][cnitro]);
 }
return 
1;

this are the lines that i'm talking about:
PHP код:
cache_get_field_content(i"owner"temp_carowner);
format(string,sizeof(string),"%s",temp_carowner);
myStrcpy(cInfo[id][carowner], string); 
Reply
#2

Show your Mystrcpy. If its for copying that string inside cInfo[id][carowner] why you just dont use this?

PHP код:
format(cInfo[id][carowner],24,"%s",temp_carowner);//24 is max name size 
and are you sure that column is owner?
Reply
#3

Quote:
Originally Posted by ilijap
Посмотреть сообщение
Show your Mystrcpy. If its for copying that string inside cInfo[id][carowner] why you just dont use this?

PHP код:
format(cInfo[id][carowner],24,"%s",temp_carowner);//24 is max name size 
and are you sure that column is owner?
the column is owner, yez.
trying that rn

edit:
wow it was in the code before that

.
Reply
#4

Welp i fixed that thing; now everything works, BUT, when i load up the server, the car didn't spawn, even tho it is in the database.
Full code:
PHP код:
forward onPlayerCarLoad(playerid);
public 
onPlayerCarLoad(playerid)
{
new 
num_fields,num_rows;
new 
temp_carowner[35],temp_plate[50];
cache_get_data(num_rows,num_fields,dbhandle);
if(!
num_rows)return 1;
 for(new 
i=0i<num_rowsi++)
 {
  
cInfo[i][db_id]=cache_get_field_content_int(i,"id",dbhandle);
  new 
id=cInfo[id][db_id];
  
cInfo[id][carmodelid]=cache_get_field_content_int(i,"model",dbhandle);
  
cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
  
cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
  
cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
  
cInfo[id][c_r]=cache_get_field_content_float(i,"a",dbhandle);
  
cInfo[id][c_color1]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_color2]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_respawntime]=cache_get_field_content_int(i,"autorespawn",dbhandle);
  
cache_get_field_content(0"plate"temp_plate);
cache_get_field_content(0"owner"temp_carowner);
format(cInfo[id][plate],30,"%s",temp_plate);
format(cInfo[id][carowner],24,"%s",temp_carowner);

CreateVehicle(cInfo[id][carmodelid],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][c_color1],cInfo[id][c_color2],cInfo[id][c_respawntime]);
cInfo[id][cnitro]=cache_get_field_content_int(i,"nitro",dbhandle);
AddVehicleComponent(id,cInfo[id][cnitro]);
}
return 
1;
}
loadPlayerCars(playerid)
{
new 
query[128],name[35];
GetPlayerName(playerid,name,35);
format(query,sizeof(query),"SELECT * FROM vehicles WHERE owner='%s'",name);
mysql_function_query(dbhandle,query,true,"onPlayerCarLoad","i",playerid);

(OnPlayerConnect has loadPlayerCars(playerid); )
Reply
#5

PHP код:
  cInfo[id][c_color1]=cache_get_field_content_int(i,"color1",dbhandle);
  
cInfo[id][c_color2]=cache_get_field_content_int(i,"color1",dbhandle); 
hello.

do i live.


.


Still same bug tho
Reply
#6

onPlayerCarLoad where are you calling this?

EDIT:nevermind. Check mysql_log if you dont have just under OnGameModeInit add mysql_log(LOG_ALL);
Reply
#7

Quote:
Originally Posted by ilijap
Посмотреть сообщение
onPlayerCarLoad where are you calling this?

EDIT:nevermind. Check mysql_log if you dont have just under OnGameModeInit add mysql_log(LOG_ALL);
nothin appeared in the logs
Reply
#8

Quote:
Originally Posted by justjamie
Посмотреть сообщение
nothin appeared in the logs
mysql_function_query...

native mysql_tquery(connectionHandle, query[], callback[] = "", format[] = "", {Float,_}:...); this is native for it :3 your is a little bit different :#


Try this:
PHP код:
mysql_format(dbhandle,query,sizeof(query),"SELECT * FROM vehicles WHERE owner='%e'",name);
mysql_tquery(dbhandle,query,"onPlayerCarLoad","i",playerid); 
If its not working maybe its something with your connection.
Reply
#9

Quote:
Originally Posted by ilijap
Посмотреть сообщение
Show your Mystrcpy. If its for copying that string inside cInfo[id][carowner] why you just dont use this?

PHP код:
format(cInfo[id][carowner],24,"%s",temp_carowner);//24 is max name size 
and are you sure that column is owner?
Why use a temp variable at all? Just fetch it directly into the destination. Genius.
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
Why use a temp variable at all? Just fetch it directly into the destination. Genius.
I only showed him example 0.0 I am using it directly . Genius.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)