Re: SQL Select?

From: Date: Sun, 25 Mar 2001 03:42:23 +0000
Subject: Re: SQL Select?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7767@lists.php.net to get a copy of this message
In article <99jh2n$gr1$1@toye.p.sourceforge.net>, gb@NOSPAMgbarrie.net ("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

« previous php.db (#7767) next »