Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Striker on Mar 08, 2016, 01:31 PM

Title: Database Querying error.
Post by: Striker on Mar 08, 2016, 01:31 PM
I've made this, but it still returns me null :| Why : [?
local q1 = QuerySQL(db, "SELECT Chocolate FROM Accessories WHERE ID ='" + object.ID + "'" );
if ( object.Model == 335 )
{
ClientMessage("You have found a Chocalate! Containing " + GetSQLColumnData( q1, 0 ) + "Vitamins!",player,255,255,0);
QuerySQL(db,"DELETE FROM Accessories WHERE ID = '" + object.ID + "' " );
object.Delete();
}
: [
Title: Re: Database Querying error.
Post by: jayant on Mar 08, 2016, 03:11 PM
One question,is the object custom ?
Title: Re: Database Querying error.
Post by: KAKAN on Mar 08, 2016, 03:27 PM
Quote from: jayant on Mar 08, 2016, 03:11 PMOne question,is the object custom ?
Quote from: Striker on Mar 08, 2016, 01:31 PMif ( object.Model == 335 )
Title: Re: Database Querying error.
Post by: Thijn on Mar 08, 2016, 04:59 PM
What returns null?
Is the row actually there? Are you sure you got the right pickup ID? Did you try printing the pickup ID and checking your database?

There's plenty of things you could do yourself to debug this..
Title: Re: Database Querying error.
Post by: Striker on Mar 08, 2016, 06:44 PM
Quote from: Thijn on Mar 08, 2016, 04:59 PMWhat returns null?
Is the row actually there? Are you sure you got the right pickup ID? Did you try printing the pickup ID and checking your database?

There's plenty of things you could do yourself to debug this..
1.Well the query get's simply fail, so whenever any thing that i want to return/get from Database returns null i.e : - ClientMessage("You have found a Chocalate! Containing null Vitamins!",player,255,255,0); also I guess you mean the object ID.
2.I did all before posting, and that's all fine, but still the same problem; however since i'm having multiple objects, so i can't take rowid.
Title: Re: Database Querying error.
Post by: Thijn on Mar 09, 2016, 06:45 AM
Yes, I meant object :)

Try printing the query, and running it yourself using a sqlite browser:
print("SELECT Chocolate FROM Accessories WHERE ID ='" + object.ID + "'");
Title: Re: Database Querying error.
Post by: Striker on Mar 09, 2016, 08:53 AM
Quote from: Thijn on Mar 09, 2016, 06:45 AMYes, I meant object :)

Try printing the query, and running it yourself using a sqlite browser:
print("SELECT Chocolate FROM Accessories WHERE ID ='" + object.ID + "'");
Well, I guess i'm noob myself no? I've created two Tables, with objects IDS, well My English will surely make you confuse, so simply.
I'm having the object with ID 49, and i'm querying the ID 39 .-. I know it's insane, lel, but topic lock. :)