Jump to content

Unable to Jump to Row Zero


unemployment

Recommended Posts

I get the unable to jump to row zero mysql error.

 

function is_admin($uid, $cid)
{
$uid = (int)$uid;
$cid = (int)$cid;

$sql =	"SELECT
			`users`.`id` AS `uid`,
			`companies`.`companyid` AS `cid`,
			`companies`.`adminid` AS `aid`
		FROM `companies`
		LEFT JOIN `users`
		ON `users`.`id` = companies.adminid
		WHERE `users`.`id` = {$uid}
		AND `companies`.`companyid` = {$cid}";

$user = mysql_query($sql);

return (mysql_result($user, 0) == '1') ? true : false;	
}

Link to comment
https://forums.phpfreaks.com/topic/236567-unable-to-jump-to-row-zero/
Share on other sites

Either your query failed due to an error or it matched zero rows.

 

You need to have error checking and error reporting logic on every query to test if the query worked of failed and then you need to test if any row(s) were returned by a successful query, all before you attempt to access the data from a query.

 

Since you are not doing either of those tests, it is not directly possible to tell you why there are no rows. Also, mysql_result() is the only mysql_ data fetch statement that produces an error simply because there were zero rows in a result set.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.