Jump to content

[SOLVED] mysql_result help


john010117

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/61028-solved-mysql_result-help/
Share on other sites

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';
}
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.