Re: [PHP] Re: REsource Identifier( PHP_MYSQL)
Gimic wrote: 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; } ? GetVals() has no ide what is $sqlQry because it is out of its scope. Try this instead GetVals($sqlQry); function GetVals($query) { //Trimmed rest $result = mysql_query($query,$db); //Trimmed } Please cc: your replies to [EMAIL PROTECTED] so others may also contribute. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: REsource Identifier( PHP_MYSQL)
[EMAIL PROTECTED] (Gimic) wrote in news:[EMAIL PROTECTED]: 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. The string $subject is almost certainly empty, as it is not passed as an argument to the function, nor is it declared global in the function. Try a little debugging, echoing your query and the output of mysql_error. For example: function GetVals() { $db = mysql_connect(localhost, root); $str_Query=(Select * from . $subject); mysql_select_db(books,$db); $result = mysql_query($str_Query); echo Query: $str_queryBR.mysql_error(); echo $result; } Then either pass $subject as an argument to the function, or declare it global within the function. Lastly, if $string is passed from another script, make sure it is populated via the GET or POST globals. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: REsource Identifier( PHP_MYSQL)
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 [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php