In article <99jh2n$gr1$[EMAIL PROTECTED]>,
[EMAIL PROTECTED] ("Grant") wrote:
> Is there any way of using a string in an SQL query instead of using the
> table name. Something along the lines of
>
> $result=mysql_query("SELECT * FROM $tablename",$db);
>
> this doesnt work it come up with a parse error
"SELECT * FROM $tablename" should be sufficient to permit PHP variable
expansion. MySQL will also require a string value to be quoted, so if
$tablename is a string, change the query to "SELECT * FROM '$tablename'".
AFAIK, the missing inner quotes would not cause a PHP parse error, only a
MySQL error. So you may want to look for something else in your code that
could be causing the parse error.
--
CC
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]