guymclaren Posted April 1, 2009 Share Posted April 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/152040-solved-empty-result-breaks-script/ Share on other sites More sharing options...
guymclaren Posted April 1, 2009 Author Share Posted April 1, 2009 if ($objRS == "") { changed to $rows = mysql_num_rows($objRS); if ($rows == 0) { Quote Link to comment https://forums.phpfreaks.com/topic/152040-solved-empty-result-breaks-script/#findComment-798468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.