Rick Danger
asked on
MySQL_result warning: "Unable to jump to row 0 on MySQL result"
Hi,
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/publi c_html/for ms/votereg .php on line 25
I found the votereg.php form, and the 25th line. This is the info from lines 7-29:
<?php
$user =& JFactory::getUser();
$userId = $user->get('username');
$userNumber = $user->get('id');
$mineid=$userId;
$db =& JFactory::getDBO();
$query = "SELECT * from jos_boarddates ORDER BY year DESC";
$db->setQuery($query);
$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.
Thanks,
RD
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/publi
I found the votereg.php form, and the 25th line. This is the info from lines 7-29:
<?php
$user =& JFactory::getUser();
$userId = $user->get('username');
$userNumber = $user->get('id');
$mineid=$userId;
$db =& JFactory::getDBO();
$query = "SELECT * from jos_boarddates ORDER BY year DESC";
$db->setQuery($query);
$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.
Thanks,
RD
ASKER
Thanks, Angell. Does it matter where I put this code?
you put that instead of the 2 lines of code you have...
ASKER
Sorry, so over: $r = mysql_query($sql);
$voting = mysql_result($r, 0, 'vote_online');
$voting = mysql_result($r, 0, 'vote_online');
yes, exactly
ASKER
Great, that's got rid of the warning message. Thanks.
Can I be sure that changing the code won't have any undesired bearings on the voting process? After people have registered, there is obviously the chance to vote itself which depends on other forms and information (sorry if this is vague!) - changing this code won't compromise or disrupt this, will it?
Can I be sure that changing the code won't have any undesired bearings on the voting process? After people have registered, there is obviously the chance to vote itself which depends on other forms and information (sorry if this is vague!) - changing this code won't compromise or disrupt this, will it?
ASKER
Hi, are you still able to help? There's still the problem of people registering multiple times, or those who registered last year mistakenly re-registering again this year.
Would very much appreciate further assistance.
Would very much appreciate further assistance.
it should not disrupt ...
but as you said, it's quite vague, so I don't know how you determine that the "people" are the same than "last year" ...
but as you said, it's quite vague, so I don't know how you determine that the "people" are the same than "last year" ...
ASKER
Well we keep a record of people (lets call them members, it's more accurate) who have registered to vote online in our database. The database is linked to the website.
Going back to the php, on line 82 of the original form there is the following:
<? if ($voting == 'yes') { echo "You have already registered to vote online.Please return to the site between <? echo $open; ?> and <? echo $close; ?> to cast your vote. If this is incorrect, please email the communications team through communications@directors.u k.com"; } ?>
<? if ($voting != 'yes') { ?>
I think the code you gave me earlier now negates that message, as I'm able to register multiple times. Could you help with this please?
Going back to the php, on line 82 of the original form there is the following:
<? if ($voting == 'yes') { echo "You have already registered to vote online.Please return to the site between <? echo $open; ?> and <? echo $close; ?> to cast your vote. If this is incorrect, please email the communications team through communications@directors.u
<? if ($voting != 'yes') { ?>
I think the code you gave me earlier now negates that message, as I'm able to register multiple times. Could you help with this please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, thanks for that. Having spoken to my colleague I may have got slightly confused with this, so in fact your new code may have been all that was needed. I'll let you know shortly.
Can I just ask what your new code added that was absent from the original? Thanks.
Can I just ask what your new code added that was absent from the original? Thanks.
the code added the control if there is a record returned or not ...
without that, and the "error ignored", you may get "obscure" side effects (because of NULL value processing ...)
without that, and the "error ignored", you may get "obscure" side effects (because of NULL value processing ...)
ASKER
Right, so that's probably what caused the warning then?
exactly
ASKER
Just spoken to my colleague and all's now working as it should.
Thanks for all your help. I'm happy to award the points to you.
Thanks for all your help. I'm happy to award the points to you.
so you have to test first:
Open in new window