From: glmlc at hotmail dot com
Operating system: Windows 2000
PHP version: 4.3.4
PHP Bug Type: MySQL related
Bug description: mysql_query not returning the Resource ID
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 bug report at http://bugs.php.net/?id=27727&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27727&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27727&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27727&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27727&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27727&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27727&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27727&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27727&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27727&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27727&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27727&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27727&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27727&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27727&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27727&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27727&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27727&r=float