FreePgs.com Forum

FreePgs Related => Support Requests => Topic started by: sixthcrusifix on May 18, 2006, 01:13:36 PM

Title: DEMONIC SQL problems!
Post by: sixthcrusifix on May 18, 2006, 01:13:36 PM
Okay can anyone help me, When ever I do this:

$SQL = "select * from USER_characters where username = \"$username\" and character = \"$chara\"";

I get this horrible "not a valid MySQL Resource" Error.



But if I leave off : and character = \"$chara\"

and just use this: $SQL = "select * from USER_characters where username = \"$username\" ";

Everything works just fine. Now this works now because I only have a single row of Data for testing, but I NEED to select my data by BOTH of those. Why the hell is it giving me the error just for trying to add a requisite? I KNOW that the value of the second one perfectly matches the value in the DB, the Character name is correct, I've checked it many times.
Title: Re: DEMONIC SQL problems!
Post by: neosquared on May 19, 2006, 07:54:17 AM
Quote from: sixthcrusifix on May 18, 2006, 01:13:36 PM
When ever I do this:

$SQL = "select * from USER_characters where username = \"$username\" and character = \"$chara\"";

I get this horrible "not a valid MySQL Resource" Error.

Could it be that character is a reserved word?  I've had issues with those before, and I dare say I would have described them as demonic, too.
Try this, see if it works:

$SQL = "select * from USER_characters where `username` = \"$username\" and `character` = \"$chara\"";
Quoted (if you could call those quotes, can't remember what they're called in any case) both column names, just in case.

Aside from that, I can't see anything wrong with your query - it all looks good to me.
Title: Re: DEMONIC SQL problems!
Post by: sixthcrusifix on May 21, 2006, 08:10:08 PM
Yes it ended up just being that Character is a reserved name :C I chanegd it to "charname" and it works fine. Thanks :D
Title: Re: DEMONIC SQL problems!
Post by: garyr_h on May 22, 2006, 03:36:13 AM
You could have just tried using slanted quotes ` around the column name.
Title: Re: DEMONIC SQL problems!
Post by: sixthcrusifix on May 23, 2006, 03:16:29 AM
Quote from: garyr_h on May 22, 2006, 03:36:13 AM
You could have just tried using slanted quotes ` around the column name.

I really think that I did and it still didn't work, I tried it like 6 different ways I can't imagine I forgot that one...