Jump to content

[SOLVED] Empty result breaks script


guymclaren

Recommended Posts

This code works fine if there is a result, but if there is no result from the db I get an error as below. How do I resolve this problem.

 

If ($name != NULL){
	If ($pass != NULL) {
	//check database
			$sqlq="SELECT * FROM Clcontacts INNER JOIN Clients ON Clcontacts.Company=Clients.id WHERE Clcontacts.email = '".$name."' AND Clcontacts.password = '".$pass."'";
			$objRS = mysql_query($sqlq);
          if ($objRS == "") {
						echo "<h2>Log in failed</h2>The username or password is incorrect, please try again";
?>
						<h2>Log In</h2>
						<form action="login.php" method="GET">
						<table>
						<tr><td>user name: (email address)</td><td><input type="text" name="uname" /></td></tr>
						<tr><td>Password:</td><td><input type="password" name="pass" /></td></tr>
						<tr><td></td><td><input type="submit" value="Submit" /></td></tr></table>
						</form>
<?					}
				else {
						$email = mysql_result($objRS, 0,"Clcontacts.email");
						$name1 = mysql_result($objRS, 0,"Clcontacts.name");
						$uid1 = mysql_result($objRS, 0,"Clcontacts.id");
						$coid1 = mysql_result($objRS, 0,"Clients.id");
						$status1 = mysql_result($objRS, 0,"Clcontacts.status");

						setcookie("user",$name1, time()+14400);
						setcookie("userid",$uid1, time()+14400); 
						setcookie("coid",$coid1, time()+14400);
						setcookie("login","yes", time()+14400);
						setcookie("status",$status1, time()+14400);

						echo  "Welcome ".$name1.", You have succesfully logged in.<br /><br />";

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 41

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 42

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 43

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 44

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /var/www/vhosts/xxxx.com/httpdocs/catalogue/login.php on line 45

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.