View Single Post
Old 02-01-2013, 05:42 PM   PM User | #1
needsomehelp
Regular Coder

 
Join Date: Oct 2009
Posts: 309
Thanks: 4
Thanked 3 Times in 3 Posts
needsomehelp can only hope to improve
mysql_result to mysqli ?

I have managed to convert all but a few of my files but just came across the largest file of all that has stacks of these sort of lines...
Code:
if (mysql_result($res, 0 ,'verified') == "Yes") {
}
what is the correct way to check the value of the results using mysqli ?




here is some more of the code...
i have changed the first part of the first IF but the rest is where i am failing.
Code:
$res = db_query($mysqli, $sql);
		if(@$res->num_rows && @mysql_result($res, 0 ,'verified') == "Yes" && @mysql_result($res, 0 ,'suspended') == "No") {
					if(@mysql_result($res, 0 ,'changeofpasswordcode') != "") {
					$randomcode = @mysql_result($res, 0 ,'changeofpasswordcode');
					} else { $randomcode = createPasswordResetCode();
							}
		// do something
		}




i tried this but not getting very far.. EDITED
Code:
$res = db_query($mysqli, $sql);
		if($res->num_rows &&
		 $res->fetch_object()->verified == "Yes"
		 && $result->fetch_object()->suspended == "No") {
					if($res->fetch_object()->changeofpasswordcode != "") {
					$randomcode = $res->fetch_object()->changeofpasswordcode;
					} else { $randomcode = createPasswordResetCode();
							}
		// do something
		}
the line that kicks up a problem is
Code:
&& $result->fetch_object()->suspended == "No") {
showing...
Trying to get property of non-object




I think it is trying to advance to the next row when there are no more.


how do i read the same row ?

Last edited by needsomehelp; 02-01-2013 at 06:47 PM..
needsomehelp is offline   Reply With Quote