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
https://forums.phpfreaks.com/topic/152040-solved-empty-result-breaks-script/
Share on other sites

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.