mySQL keyword in query, how to handle?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dwessell
Forum Commoner
Posts: 62
Joined: Fri Dec 23, 2005 2:30 pm

mySQL keyword in query, how to handle?

Post by dwessell »

Hey all.. I have a query that goes something like this:

Code: Select all

"UPDATE ItemInformation SET ItemUsed = 1, LastItem = 1 WHERE GameNumber = `$row[0]` AND 
				TeamNumber = $innerRow[2] and Item = $itemResult[0]";
$itemResult[0] might possibilty contain a SQL keyword, like from.. How can I handle this?

Thanks
David
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

You mean the value of $itemResult[0] could = "FROM"

That should be ok.

Code: Select all

$itemResult[0]  = "FROM";

"UPDATE ItemInformation SET ItemUsed = 1, LastItem = 1 WHERE GameNumber = `$row[0]` AND 
            TeamNumber = $innerRow[2] and Item = $itemResult[0]";
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

So long as it's escaped as a standard string, MySQL won't care what's in it.
Post Reply