MySQL-Unable to go to row 0 at MySQL result index

I have an old site that recently showed an error, which is strange since it has not been affected for some time. I get the following:

Unable to jump to row 0 on MySQL result index 8 

What is the reason for this and how to fix it?

This is a PHP / MySQL site.

+6
source share
2 answers

If I remember correctly, this error is usually related to the code segment as follows:

 // You probably have some code similar to this $var = mysql_result( $result, 0, 'column_name'); 

If the query fails, the column or column does not exist. Make sure $result is a valid MySQL resource to make sure SQL is valid, and then make sure you actually get the results from the database before trying to call mysql_result .

Or, even better, using mysql_fetch_array instead of manually retrieving each column value (if you have multiple columns returned from the query).

+10
source

Try to analyze the result before extracting it. If the result is empty, skip the checkout.

 $result = mysql_query("SELECT * FROM table1"); if (!$result || !mysql_num_rows($result)) { die('Empty set.'); } while ($row = mysql_fetch_array($result)) { // Your code here } 
+2
source

Source: https://habr.com/ru/post/902843/


All Articles