john010117 Posted July 20, 2007 Share Posted July 20, 2007 I believe this is my first time dealing with mysql_result(), and it's giving me an error. The part of the code: <?php $b_query = "SELECT * FROM $block_tbl_name WHERE user_select = '$session_uid' AND user = '$u' "; $b_result = mysql_query($b_query) OR DIE (mysql_error()); $b_sql_result = mysql_result($b_result, 0); ?> Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 15 Even though I was executing the query, I needed the result where user = '$session_uid' AND user_select = '$u'. I searched google, but a lot of other sites where showing the error, and there weren't any helpful information on how to actually fix it. BTW, I have 3 rows in that table. How would I solve this problem? Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/ Share on other sites More sharing options...
GingerRobot Posted July 20, 2007 Share Posted July 20, 2007 You say there are 3 rows in the table, but i dont think any of them are being retrieved. Try this to check: <?php $b_query = "SELECT * FROM $block_tbl_name WHERE user_select = '$session_uid' AND user = '$u'"; $b_result = mysql_query($b_query) OR DIE (mysql_error()); $rows = mysql_num_rows($b_result); if($rows > 0){ $b_sql_result = mysql_result($b_result, 0); }else{ echo 'No rows returned'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303693 Share on other sites More sharing options...
john010117 Posted July 20, 2007 Author Share Posted July 20, 2007 You're right. None of them are being retrieved. No rows returned So does that mean there's something wrong with my MySQL query? Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303695 Share on other sites More sharing options...
OLG Posted July 20, 2007 Share Posted July 20, 2007 yes, there is a problem with your WHERE clause, one of the variables isn't defined or doesn't match anything in the database. Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303699 Share on other sites More sharing options...
GingerRobot Posted July 20, 2007 Share Posted July 20, 2007 Well, theres not actually anything wrong with it as such - otherwise we would have an error. However, its not returned the rows you expect. Try echoing the query to see if the right values are being passed into it: <?php $b_query = "SELECT * FROM $block_tbl_name WHERE user_select = '$session_uid' AND user = '$u'"; $b_result = mysql_query($b_query) OR DIE (mysql_error()); $rows = mysql_num_rows($b_result); if($rows > 0){ $b_sql_result = mysql_result($b_result, 0); }else{ echo 'No rows returned. Query was'. $b_query; } ?> Check that make sure its querying the database with the values you are expecting. Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303700 Share on other sites More sharing options...
john010117 Posted July 20, 2007 Author Share Posted July 20, 2007 Yep, it's echoing out the correct values. Oh, god. How could I have missed this? I have put it in the wrong order. Nevermind. Thanks for helping me out. I appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303708 Share on other sites More sharing options...
GingerRobot Posted July 20, 2007 Share Posted July 20, 2007 No problem. Its always the simple things that you spend the most time over Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303712 Share on other sites More sharing options...
john010117 Posted July 20, 2007 Author Share Posted July 20, 2007 No problem. Its always the simple things that you spend the most time over I can relate to that many times. Quote Link to comment https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/#findComment-303717 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.