Chris wrote:
Na Derro Cartwright wrote:
I am currently running php4 with mysql 5. when I try to run a query
using the mysql command I recieve and error that reads the resource
id and a number. What does that mean?
Firstly always cc the list - others will be able to provide their
input and others will also learn from the problem/resolution.
What is the query? What is the error?
If you run it manually through command line mysql or phpmyadmin do you
get an error?
You're probably doing something like:
//Open connection and database
$handle = mysql_connect($host, $user, $pass);
mysql_select_db($database);
//Run query
$result = mysql_query("SELECT foo FROM bar");
//Close connection
mysql_close($handle);
//Show result
echo $result;
The correct way to do this is:
//Open connection and database
$handle = mysql_connect($host, $user, $pass);
mysql_select_db($database);
//Run query
$result = mysql_query("SELECT foo FROM bar");
//use resource id returned from query to fetch actual results (note that
the 0 is a line number so in the case you have more than 1 result you'll
have to use a different method such as mysql_fetch_assoc or something
I'd advise you take a look at the documentation @ php.net)
$result = mysql_result($result, 0);
//Close connection
mysql_close($handle);
//Show result
echo $result;
--
Thanks,
Jim
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php