MySQL Forums
Forum List  »  Newbie

How to escape SQL thinking a variable is a table?
Posted by: kamen.kozarev
Date: June 28, 2005 12:21AM

I am trying to SELECT a variable that is a filename and has a dot in it. SQL thinks I'm asking it for a column of a table. Below's the code:

($number is an input variable from an html form)

$data1 = mysql_query("select * from band_img where number = $number");

$result = mysql_fetch_array($data1);

$name = $result["name"]; (name is something like m42ix_im26May2004.003575)

$data2 = mysql_query("select * from band_ref where name = $name");

and the error I get is "Invalid query: Unknown table 'm42ix_im26May2004' in where clause"

I would appreciate your help.

Options: ReplyQuote


Subject
Written By
Posted
How to escape SQL thinking a variable is a table?
June 28, 2005 12:21AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.