Monkey644 Posted May 15, 2015 Posted May 15, 2015 Hey everyone, I am getting the following error message: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 17 in /home/a4767764/public_html/class/class_db_mysql.php on line 94 Only on my index.php page, all other pages are fine. Any advice on this? Cheers Quote
G7470 Posted May 15, 2015 Posted May 15, 2015 You have to check whether there are any results before attempting to fetch a result (which is what mysql_result() does). To do this in MCCodes v2: if(!$result || $db->num_rows($result) == 0) { //Means $result is empty } After something like this, you can then fetch the result appropriately. ~G7470 PS: FYI, the mysql_ extension has been deprecated. You should covert to mysqli_ sometime soon. Quote
Monkey644 Posted May 15, 2015 Author Posted May 15, 2015 You have to check whether there are any results before attempting to fetch a result (which is what mysql_result() does). To do this in MCCodes v2: if(!$result || $db->num_rows($result) == 0) { //Means $result is empty } After something like this, you can then fetch the result appropriately. ~G7470 PS: FYI, the mysql_ extension has been deprecated. You should covert to mysqli_ sometime soon. The snippet of code that is causing this error is: if(!$result) { $result=$this->result; } return mysql_result($result, 0, 0); } Any advice? Quote
G7470 Posted May 15, 2015 Posted May 15, 2015 The snippet of code that is causing this error is: if(!$result) { $result=$this->result; } return mysql_result($result, 0, 0); } Any advice? The code inside of the class_db_mysql.php file is fine (as I know that's where this came from). The problem is how you're calling the fetch_single() function. You have to check to see whether a row exists in the query result BEFORE attempting to fetch anything; otherwise, you're going to continue running into this problem. ~G7470 Quote
Magictallguy Posted May 15, 2015 Posted May 15, 2015 The snippet of code that is causing this error is: if(!$result) { $result=$this->result; } return mysql_result($result, 0, 0); } Any advice? Incorrect, that code is fine. Edit index.php, find any instance of $db->fetch_single , paste that and the surrounding five lines (from both sides) here. Quote
Monkey644 Posted May 16, 2015 Author Posted May 16, 2015 Incorrect, that code is fine. Edit index.php, find any instance of $db->fetch_single , paste that and the surrounding five lines (from both sides) here. Will do when I get home from work. Thanks for looking into this for me. Quote
Monkey644 Posted May 16, 2015 Author Posted May 16, 2015 Incorrect, that code is fine. Edit index.php, find any instance of $db->fetch_single , paste that and the surrounding five lines (from both sides) here. The function is: function fetch_single($result=0) { if(!$result) { $result=$this->result; } return mysql_result($result, 0, 0); } There is nothing containing fetch_single in the index.php and I have found this is happening on loggedin.php If it's any help, this has only appeared after I installed Sniko's Advanced Property Modification. Quote
KyleMassacre Posted May 17, 2015 Posted May 17, 2015 You most likely have a bad query. Look at line 17 in your index file, of i remember correctly he uses a lot of functions for this mod. Then look for that function in global funcs or his own includes that came with the mod and post both the function and definition of the function Quote
Monkey644 Posted May 17, 2015 Author Posted May 17, 2015 (edited) I have found the following within the property mod globals, which is an included file. function get_house_name($id) { global $db; $get = $db->query("SELECT `name` FROM `property_mod` WHERE `id`={$id}"); return $db->fetch_single($get); } function get_house_name_by_row($row) { global $db; $get = $db->query("SELECT `name` FROM `property_mod` WHERE `id` IN (SELECT `houseid` FROM `properties_mod_user` WHERE `id`={$row})"); return $db->fetch_single($get); } This is out of the global func file. } function get_rank($stat, $mykey) { global $db; global $ir,$userid,$c; $q=$db->query("SELECT count(*) FROM userstats us LEFT JOIN users u ON us.userid=u.userid WHERE us.$mykey > $stat AND us.userid != $userid AND u.user_level != 0") ; return $db->fetch_single($q)+1; } function item_add($user, $itemid, $qty, $notid=0) { global $db; if($notid > 0) { Edited May 17, 2015 by Monkey644 Quote
KyleMassacre Posted May 17, 2015 Posted May 17, 2015 For the 2 in property mod globals I would add: if($db->num_rows($get)) { return $db->fetch_single($get); } else { return false; } Quote
Monkey644 Posted May 20, 2015 Author Posted May 20, 2015 For the 2 in property mod globals I would add: if($db->num_rows($get)) { return $db->fetch_single($get); } else { return false; } You're awesome! No more error. Thank you very much for everyones help and input. Quote
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.