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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.