On Sat, Mar 24, 2001 at 08:55:13PM -0000, 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

Your problem is probably on a line above this one.  Because this line
should be valid.  I do stuff like  this all the time and it works
without any problems so far.

// First of all, I use a variable to hold my sql statement:
$sql = "select * from $tablename";
// Then perform the query:
$result = mysql_query($sql, $db) or die("$sql<br>".mysql_error($db));

This allows you to see the sql that is actually being executed, and you
also get to see the actual mysql error.
Jason Stechschulte
It is, of course, written in Perl.  Translation to C is left as an
exercise for the reader.  :-)  -- Larry Wall in <[EMAIL PROTECTED]>

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]

Reply via email to