SA-MP Forums Archive
Sql INSERT INTO Error - 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: Sql INSERT INTO Error (/showthread.php?tid=649735)



Sql INSERT INTO Error - Zerw - 14.02.2018

Hi everyone i am using this function

Код:
	new Query[308];
	format(Query, sizeof Query, "INSERT INTO vehicles (ownername, price, model) VALUES ('%q', %d, %d)", "NONE", vehicleInfo[vid][vprice], vehicleInfo[vid][vmodel]);
	db_query(VehDB, Query);
it gives me this error i dont know what the error means can anyone explains it to me :

[Error] db_query: invalid database handle 0


Re: Sql INSERT INTO Error - Mugala - 14.02.2018

db_query(VehDB, Query); here must be your SQL handle, which you created when you was connecting to MySQL (for example: mydb = mysql_connect(... )
also this must be created with MySQL tag (new MySQL:mydb; )


Re: Sql INSERT INTO Error - Zerw - 14.02.2018

i am using sqlite not mysql


Re: Sql INSERT INTO Error - Mugala - 14.02.2018

agh, my bad, problem is same.
you have to use new DB:mydb;
and mydb = db_open(...
db_query(mydb,Query);


Re: Sql INSERT INTO Error - Zerw - 14.02.2018

opps my bad i created vehicles before opening the database under OnGameModeInit thanks