Cognito Posted February 12, 2008 Share Posted February 12, 2008 Hi Guys, I'm trying to convert the following code from php3 syntax to php5. I've managed to convert everything except the mysql_fetch_row segment. For some reason I always get the error: mysql_fetch_row(): supplied argument is not a valid MySQL result resource function sess_read($key) { $qry = "SELECT data FROM sessions WHERE sessID = '$key' AND expires > ".time(); // New mQuery Call $res = new DB; $res->mQuery($qry, __LINE__); if (list($value) = mysql_fetch_row($res)) { return $value; } return false; } The code for the function mQuery in the class DB is: function mQuery($sql, $line=-1, $link=''){ global $mysqlLink; $res = @ mysql_query($sql); if (!$res){ trigger_error("Query failure at <i style='color:black'>$sql</i>.<br> MySQL said: ".mysql_error()."¼".$line, E_USER_ERROR); } return $res; } Hope you can help guide me in the right direction Link to comment https://forums.phpfreaks.com/topic/90655-converting-php3-to-php5/ Share on other sites More sharing options...
aschk Posted February 12, 2008 Share Posted February 12, 2008 You're confusing your variable names and their scope Change this : function sess_read($key) { $qry = "SELECT data FROM sessions WHERE sessID = '$key' AND expires > ".time(); // New mQuery Call $res = new DB; // <==== this is an object not a query result! $queryResult = $res->mQuery($qry, __LINE__); if (list($value) = mysql_fetch_row($queryResult)) { return $value; } return false; } Link to comment https://forums.phpfreaks.com/topic/90655-converting-php3-to-php5/#findComment-464692 Share on other sites More sharing options...
Cognito Posted February 12, 2008 Author Share Posted February 12, 2008 Cheers for the reply aschk that makes alot more sense now! Previously it was a variable but I changed it to an object as I was getting errors about static and non-static :S Seems to work now any how Thanks! Link to comment https://forums.phpfreaks.com/topic/90655-converting-php3-to-php5/#findComment-464697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.