vyb3 Posted October 20, 2008 Share Posted October 20, 2008 I've got a very strange error on my site (www.vyb3.co.uk) Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 44 in /home/fhlinux159/v/vyb3.co.uk/user/htdocs/vyb308/news/index.php on line 46 ####@@@**split**@@@###Please enter a name.####@@@**split**@@@### The error appears in a completely different place on my site to where I installed the script thats resulted in this error, Its a vbulletin login script to allow users to be able to login to the site on the homepage as well as in the forums (because im going to password protect some pages) But yeah the code for this login box is: This code is displayed at the top of my page before the <html> tag <?php $curdir = getcwd (); chdir('../forum'); require_once('../forum/global.php'); chdir ($curdir); ?> Then this code is placed where I want my login box to be. <?PHP $forumpath = "../forum"; // We check if user is logged in if ($vbulletin->userinfo['userid']!=0) { // +++++++++++++++++++++++++++++++++++++++++ // As Logged in display welcome back message // +++++++++++++++++++++++++++++++++++++++++ echo "Welcome Back, <b>"; echo $vbulletin->userinfo['username']; echo " !</b><br />"; // As were logged in display logout link echo "<a href=\"".$forumpath."login.php?$session[sessionurl]do=logout&logouthash=$logouthash"; echo $vbulletin->userinfo['logouthash']; echo "\">"; echo "<font size=\"1\" face=\"verdana\">Log Out</font></a><br />"; // Display last visit time and date echo "You last visited: $pmbox[lastvisitdate] at $pmbox[lastvisittime]"; echo "<br />"; // Display PM Details and generate link to PM box echo "<a href=\"".$forumpath."private.php?$session[sessionurl] \">Private Messages: </a> $vbphrase[unread_x_nav_compiled] $vbphrase[total_x_nav_compiled]"; echo "<br />"; } else { include("login_vb.php"); } ?> Then this is the code for login_vb.php <form action="../forum/login.php?do=login" method="post" onSubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, $show[nopasswordempty])"> <input type="hidden" name="do" value="login" /> <input type="hidden" name="url" value="http://www.vyb3.co.uk/vyb308/index.php?vyb3=main" /> <input type="hidden" name="vb_login_md5password" /> <input type="hidden" name="vb_login_md5password_utf" /> <input type="hidden" name="s" value="$session[sessionhash]" /> <label>Username:<input name="vb_login_username" type="text" class="bginput" id="login" accesskey="u" tabindex="1" size="12"/> </label> <label><br> Password: <input name="vb_login_password" type="password" class="bginput" id="password" tabindex="1" size="12" /> </label> <label><br> Remember me? <input type="checkbox" name="cookieuser" value="1" id="cb_cookieuser" tabindex="1" /></label> <br> <input name="submit" type="submit" id="submit" tabindex="1" value="Login" accesskey="s" class="button" /> </form> And the error displays on a completely different part of the site... Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/ Share on other sites More sharing options...
vyb3 Posted October 20, 2008 Author Share Posted October 20, 2008 Why has this been moved this script is not a 3rd party script... Its to do with a 3rd party script... Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-670417 Share on other sites More sharing options...
nonexistentera Posted October 21, 2008 Share Posted October 21, 2008 Hey there. Im not sure, but I have used this before. http://forums.mysql.com/read.php?52,142673,200941#msg-200941 In your script, wherever you run the mysql_result(); try doing mysql_num_rows() before using mysql_result() and see if you get anything back. $sql = "Whatever"; $query = mysql_query($sql); $numRows = mysql_num_rows($query); echo $numRows; Try that and tell us whet you get. If it's 0, you have no records. Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-670591 Share on other sites More sharing options...
vyb3 Posted October 21, 2008 Author Share Posted October 21, 2008 Its wierd though because I dont have any mysql num code in the piece of code i've added which has caused this.... Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671330 Share on other sites More sharing options...
vyb3 Posted October 21, 2008 Author Share Posted October 21, 2008 Ok i have figured it out the problem is coming from the index file of my news script... $delimiter = '####@@@**split**@@@###'; I found that piece of code in there.... Still I don't know what to change to make this error go away, it has also caused my news categories search function to malfunction.... This is really doing my head in! Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671339 Share on other sites More sharing options...
vyb3 Posted October 22, 2008 Author Share Posted October 22, 2008 $query = mysql_query($sql); $allowcomments = mysql_result($query,0); echo $delimiter; $message = slash2($_POST['message']); $message = str_replace($delimiter ,"",$message); $name = slash2($_POST['name']); $name = str_replace($delimiter,"",$name); $email = slash2($_POST['email']); $email = str_replace($delimiter,"",$email); if(!$name){ echo "Please enter a name."; }elseif(!$message){ echo "Please enter a message."; }else{ if($allowcomments == "1" || $allowcomments == "2"){ $sql2 = "SELECT * FROM $newsusers WHERE user = '". $name . "'"; $query2 = mysql_query($sql2); $ex = mysql_num_rows($query2); if(time() - $_SESSION['lastmsg'] <= $spamtime){ $spammsg = str_replace("{timeleft}",($spamtime - (time() - $_SESSION['lastmsg'])),$spammsg); echo $spammsg; }else{ $user = slash2($_POST['name']); $user = str_replace($delimiter ,"",$user); $message = slash2($_POST['message']); $message = str_replace($delimiter ,"",$message); $email = slash2($_POST['email']); $email = str_replace($delimiter ,"",$email); $timestamp = time(); $ip = $_SERVER['REMOTE_ADDR']; $pid = slash2($id); $all = mysql_fetch_array($query2); if($allowcomments == "1"){ $approved = '1'; }elseif($allowcomments == "2"){ $approved = '0'; } $sql = "INSERT INTO $newscomments (user,email,message,timestamp,approved,ip,pid) VALUES ('$user','$email','$message','$timestamp','$approved','$ip','$pid')"; if($ex == 1){ if($_SESSION['name'] == $all['user']){ $_SESSION['lastmsg'] = time(); $query = mysql_query($sql) or die(mysql_error()); if($allowcomments == "1"){ echo $commentmsg; }elseif($allowcomments == "2"){ echo $commentapprovemsg; } }else{ echo "Choose another name."; } }else{ $_SESSION['lastmsg'] = time(); $query = mysql_query($sql) or die(mysql_error()); if($allowcomments == "1"){ echo $commentmsg; }elseif($allowcomments == "2"){ echo $commentapprovemsg; } } } }else{ #incase anyone tries adding comments to posts which have comments disabled echo "Nice try"; } } } echo $delimiter; } Line 46 which the error message displays is: $allowcomments = mysql_result($query,0); So any ideas peeps? i'm trying.... Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671342 Share on other sites More sharing options...
nonexistentera Posted October 22, 2008 Share Posted October 22, 2008 the mysql_result() looking in row 0 which is giving you this error. Try changing it to $allowcomments = mysql_result($query, 1); And tell me what you get. Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671388 Share on other sites More sharing options...
vyb3 Posted October 22, 2008 Author Share Posted October 22, 2008 I tried that man Warning: mysql_result() [function.mysql-result]: Unable to jump to row 1 on MySQL result index 25 in /home/fhlinux159/v/vyb3.co.uk/user/htdocs/vyb308/news/index.php on line 46 ####@@@**split**@@@###Please enter a name.####@@@**split**@@@### this is real baffling me u no Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671613 Share on other sites More sharing options...
nonexistentera Posted October 22, 2008 Share Posted October 22, 2008 This is strange. What is your SQL for the comments mysql_result->$query->$sql Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671694 Share on other sites More sharing options...
vyb3 Posted October 22, 2008 Author Share Posted October 22, 2008 How do I go about finding that information? Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-671882 Share on other sites More sharing options...
nonexistentera Posted October 22, 2008 Share Posted October 22, 2008 Whatever the $sql = "Your Statement"; is equal to. Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-672209 Share on other sites More sharing options...
vyb3 Posted October 22, 2008 Author Share Posted October 22, 2008 $sql = "SELECT allowcomments FROM $newstable WHERE id = '".slash2($id) . "'"; Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-672230 Share on other sites More sharing options...
nonexistentera Posted October 23, 2008 Share Posted October 23, 2008 Do you know what the slash2 is suppose to be. It looks like a function, which if so, could you post it. If it's a variable though you are missing the $ which could be causing you to have no rows, giving you your error. Quote Link to comment https://forums.phpfreaks.com/topic/129310-unable-to-jump-to-row-0-mysql/#findComment-672336 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.