MySQL Resource id #
I request a password from a remote server, store in a database table and recover it for use in several URL requests, and am able to retrieve xml data which I can then display on my pages.
This seems to work fine, except in addition to the xml data, the code also seems to output strings that looks like this:
Resource id #[random number]
Does anyone know what this might be due to?
My code to recover the p开发者_StackOverflow社区assword from the db looks like this:
$result = mysql_query("SELECT * FROM db_table WHERE id=1")
or die(mysql_error());
$row = mysql_fetch_array($result);
$my_info = $row['id_string'];
Thanks!
Thats a string conversion of a php resource like your db handle, result from a db query, or a file handle (retunred from fopen). Somewhere you are doing something like
echo $result;
as opposed to
echo $my_info;
That's the string that results when echoing the, uh, result. The solution is to stop echoing it.
if you're getting resource id#, it means that you echo $result.
And on another note: if you need only one value, I'd suggest using the following:
$id_string = mysql_result($result, 0, 'id_string');
精彩评论