#27727 [Opn]: mysql_query not returning the Resource ID

From: Date: Sat, 27 Mar 2004 06:37:37 +0000
Subject: #27727 [Opn]: mysql_query not returning the Resource ID
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56938@lists.php.net to get a copy of this message
ID: 27727 User updated by: glmlc at hotmail dot com Reported By: glmlc at hotmail dot com Status: Open Bug Type: MySQL related Operating System: Windows 2000 PHP Version: 4.3.4 New Comment: >Keep in mind that the info stored in the $_POST is >selected from a table in the db called "books". correction: it is a table in the db called "books".. Previous Comments: ------------------------------------------------------------------------ [2004-03-27 01:23:22] glmlc at hotmail dot com Description: ------------ I used the MySql_Query with an argument put together as a string, part of it included the $_POST varible, and when passing the string to the MySql_Query I got no error, yet no resource id to use for the rest of my function. I have tried to force the stringtype to the varible and that still didn't work. Keep in mind that the info stored in the $_POST is selected from a table in the db called "books". Yet when I hard code the same format in the string it returns it. Only get the problem when I use the varible. Reproduce code: --------------- <?php if ($_POST != 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); echo $result; } ?> Expected result: ---------------- I expect it to echo the resource ID. This was a test code I developed while debugging the rest of the project. I leveled it down to this problem. It's not allowing me to use any of the rest of the mysql functions because the resource id is non-existant. I don't get errors until I try to use functions like MySql_fetch_row($result) and whatnot, and those errors say that the argument it invalid. Actual result: -------------- null is stored in $result, leaving me high and dry for the rest of the project. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27727&edit=1

« previous php.bugs (#56938) next »