...

View Full Version : mysql_fetch_assoc warning after upgrading from PHP 5.29 to 5.30



starvos
03-23-2010, 04:55 PM
I have been using the codes below under PHP v5.29 without any errors.


$SQL = "SELECT * FROM (users,admin) WHERE users.ref=$ref & admin.ref=$ref";
$result = mysql_query($SQL);
$db = mysql_fetch_assoc($result);


But, after upgrading to v5.30, the following errors occurs :

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in D:\www\profile.php on line 9

Does anyone know what's going on??

Fumigator
03-23-2010, 05:16 PM
Try checking $result to see if it's false before you attempt to use it (which you should already be doing to catch query failures).

JAY6390
03-23-2010, 05:30 PM
Yep. By the sounds of it you have an error in your query
echo SQL to see if the query looks wrong. also echo out mysql_error() in case it's a connection/db selection fault

Fou-Lu
03-23-2010, 05:47 PM
Does SQL like bitwise and to separate two conditions within a where clause?
Methinks this query has never worked, and you're new version of PHP has been set to display errors while you're previous had not been.

starvos
03-23-2010, 07:06 PM
Nevermind~ just realised that I didn't set the short open tag on after the upgrade and that is causing the problems... :(

Fumigator
03-23-2010, 08:50 PM
Nevermind~ just realised that I didn't set the short open tag on after the upgrade and that is causing the problems... :(

Even so, you should still be checking your queries for errors :thumbsup:

Fou-Lu
03-23-2010, 10:04 PM
Nevermind~ just realised that I didn't set the short open tag on after the upgrade and that is causing the problems... :(

I'm not sure how that can be actually causing this issue though. Clearly the error is a PHP one which would indicate that PHP is being properly parsed. Obviously short_open_tags will cause problems, but in this case that does not appear to be the issue :confused:
Unless of course the code is technically different than what has been posted here?

JAY6390
03-23-2010, 10:06 PM
db connection data could be in short tags I guess, and that wasn't parsed, so no connection and no result is returned?

Fou-Lu
03-23-2010, 10:13 PM
db connection data could be in short tags I guess, and that wasn't parsed, so no connection and no result is returned?

Good call on that one!
Fumigator is still right though, should always have a check of some sorts. Still not 100% certain about that bitwise handling, but when I attempt to throw it at an SQLServer it don't like it too much. I would presume that MySQL is not alright with it too. Access takes it though, but doesn't do anything with it; appears it doesn't support bitwise.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum