MySQL_result warning: "Unable to jump to row 0 on MySQL result"
Posted on 2010-09-15
I have a very limited knowledge of MySQL, and am working off php code created by somebody else. The company I work for has an annual vote, which members can register to do online if they wish. As the registration process begins soon, I have been testing this today. It might also be worth noting the company uses Joomla.
I am testing the functionality of the Vote Registration form, which is where the problem occurs. After making the relevant pages live, the opening page (where members input their details if they wish to vote online when the opportunity arises) opens with a warning message. It reads:
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 158 in /home/directorsukcom/public_html/forms/votereg.php on line 25
I found the votereg.php form, and the 25th line. This is the info from lines 7-29:
$user =& JFactory::getUser();
$userId = $user->get('username');
$userNumber = $user->get('id');
$db =& JFactory::getDBO();
$query = "SELECT * from jos_boarddates ORDER BY year DESC";
$row = $db->loadObject();
$open = $row->open;
$close = $row->close;
$regclose = $row->regclose;
$sql = "SELECT * from jos_dprsprofile WHERE userid = '$userNumber'";
$r = mysql_query($sql);
$voting = mysql_result($r, 0, 'vote_online');
Line 25 is in bold ($voting = mysql_result($r, 0, 'vote_online');). Having looked at JoomMyAdmin > PhPMyAdmin Control Panel, I found the form jos_dprsprofile. As 168 people chose to vote online last year, those same people have a yes in the vote_online column. My understanding is these people mistakenly registered to vote online again, they would be told that they've already registered. But I don't see why this should cause the warning message - perhaps it's not functioning as it should.
I hope I've given enough information, but please let me know should you need more. I would appreciate an answer soon.