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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.