Warning: mysql_result(): Unable to jump to row 0 ....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
justravis
Forum Commoner
Posts: 53
Joined: Mon Dec 16, 2002 3:18 am
Location: San Diego, CA
Contact:

Warning: mysql_result(): Unable to jump to row 0 ....

Post by justravis »

Getting this error:
Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 4

What is the usual cause of this?

Thanks for your time.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

justravis wrote:What is the usual cause of this?
There is no row 0?

Could we see your code in order to be able to help you better.

Mac
justravis
Forum Commoner
Posts: 53
Joined: Mon Dec 16, 2002 3:18 am
Location: San Diego, CA
Contact:

Post by justravis »

$org & $web are submitted through a form.

There is one record in the org table:
id name url
1 justravis justravis.com

Code: Select all

<?php
#Returns 1 piece of data from database.  Ex: 1 cell, count, max.
function cell($query)
{
        $result=mysql_query($query);

        #mysql_result($result, row, col): returns 1 cell, specifying col optional.
        $cell=mysql_result($result, 0);

        return $cell;
}

                if($org || $web)
                {
                        $org_id=cell("SELECT id FROM org WHERE name='$org'");

                        if($org_id && $web)
                        {
                                mysql_query("UPDATE org SET url=$web WHERE id=$org_id");
                        }
                        else
                        {
                                mysql_query("INSERT INTO org (name, url,) VALUES ('$org', '$web')");
                                $org_id=mysql_insert_id();
                        }
                }

?>
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

you are sure that $query is correct?

the other option for that is to use mysql_fetch_array

Code: Select all

<?php
function cell($query) 
{ 
        $result=mysql_query($query); 

        if($cell=mysql_fetch_array($result));
           return $cell['item'];
        else
           return 'err';
}
                if($org || $web) 
                { 
                        $org_id=cell("SELECT id FROM org WHERE name='$org'"); 

                        if($org_id && $web && ($org_id!='err')) 
                        { 
                                mysql_query("UPDATE org SET url=$web WHERE id=$org_id"); 
                        } 
                        else 
                        { 
                                mysql_query("INSERT INTO org (name, url,) VALUES ('$org', '$web')"); 
                                $org_id=mysql_insert_id(); 
                        } 
                } 

?>
excluding syntax, that should work

[edit] since the error you are getting implies that your query returns no results, if you still have trouble try: echo mysql_error();
:)
[/edit]
Post Reply