Re: REsource Identifier( PHP_MYSQL)

From: Date: Sat, 27 Mar 2004 07:55:01 +0000
Subject: Re: REsource Identifier( PHP_MYSQL)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-181609@lists.php.net to get a copy of this message
The entire script looks like this: <?php if ($_POST["Subject"] != NULL) { echo "results for " . $_POST["Subject"]; $subject = $_POST["Subject"]; $qry = ("select * from " . $subject); $sqlQry = (string) $qry; GetVals(); } function GetVals() { $db = mysql_connect("localhost", "root"); mysql_select_db("books",$db); $result = mysql_query($sqlQry,$db); echo mysql_errno($db); echo mysql_error($db); echo $result; } ?> Where the name of the table is stored in the $_POST varible. The string isn't empty, yet it is empty. It may be a bug... Or do any of you see any problem with my varible scope? because I don't. "Gimic" <glmlc@hotmail.com> wrote in message news:20040327054050.19385.qmail@pb1.pair.com... > Hey y'all, I'm having problems trying to get the > MySql_Query() function to return the resource ID when using a $string as the > argument to pass to it. It returns when I hard code the argument but not the > string. Any ideas? here is what the function looks like: > > function GetVals() { > $db = mysql_connect("localhost", "root"); > $str_Query=("Select * from " . $subject); > > mysql_select_db("books",$db); > > $result = mysql_query($str_Query); > echo $result; > > } > but when I use the query: > $result=mysql_query("Select * from math") it works. Am I setting my string > up wrong? Because it's not running into any errors when I do this.

« previous php.general (#181609) next »