|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-27 01:37 UTC] glmlc at hotmail dot com
[2004-03-27 04:40 UTC] glmlc at hotmail dot com
[2004-03-27 04:54 UTC] abies@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 07:00:01 2025 UTC |
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.