php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27727 mysql_query not returning the Resource ID
Submitted: 2004-03-27 01:23 UTC Modified: 2004-03-27 04:54 UTC
From: glmlc at hotmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.4 OS: Windows 2000
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: glmlc at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-03-27 01:23 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-27 01:37 UTC] glmlc at hotmail dot com
>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"..
 [2004-03-27 04:40 UTC] glmlc at hotmail dot com
PLease disregard this post.  It was brought to my attention that certain elements were out of scope.
 [2004-03-27 04:54 UTC] abies@php.net
. 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 07:00:01 2025 UTC