This seems to be a very easy issue for someone experienced with PHP, but I am not (apparently)...
Ok, I have been sweating over this for quite some time now (maybe a week, on and off?):
I have a table where I plan to write session information: 'Session' is this tables name.
I have a couple of lines in there already, but since my site isn't finalised, I keep deleting them and only keep line 1.
This doesn't really matter, I guess, because all I want to query is the highest number in that table...
Not so difficult one should imagine:
Code: Select all
<?
$result = mysql_query("select max(SessionID) from Session") or die(mysql_error());
$rest = mysql_fetch_field($result, 0);
echo " Top 1 SessionID is: ". $rest;
?>
So, I donno, but I think PHP doesn't need to convert variables, isn't that correct? So it doesn't really matter that my string is actually an int.Catchable fatal error: Object of class stdClass could not be converted to string in {...(line "echo...")}
I seem to be struggling quite a bit with the fetch-part. I can't fetch this into an array, no object, nothing. (<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> me off)
If I comment the "echo" line out, it works fine, no error.
Is the $result empty? Is there a way to tell (other than fetching it)?
The query works fine in a query browser, so I think this statement should be legit? - It should give me some error if it wasn't, right?
Any other suggestions how I might be able to debug?
Thanks again in advance!
Best,
Chris