News:

Click here for Toll-Free Service for your business starting at $2.00 per month

Main Menu

DEMONIC SQL problems!

Started by sixthcrusifix, May 18, 2006, 01:13:36 PM

Previous topic - Next topic

sixthcrusifix

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.
Visite me website at http://www.sixthcrusifix.com

neosquared

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.
Don't take servers for granted.
Everything is flammable, if you get it hot enough.
Visit my website!  It'll make you cooler!

sixthcrusifix

Yes it ended up just being that Character is a reserved name :C I chanegd it to "charname" and it works fine. Thanks :D
Visite me website at http://www.sixthcrusifix.com

garyr_h

You could have just tried using slanted quotes ` around the column name.

sixthcrusifix

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...
Visite me website at http://www.sixthcrusifix.com