Re: Error query : mysql_result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Burgess [mailto:c.burgess@city.ac.uk] wrote:
> Hi
> 
> I have used the mysql_result function to return some specific 
> information
> from database.  The information is returned as it should but 
> I keep getting
> this error message:
> 
> Warning: Unable to jump to row 0 on MySQL result index 4 in
> /u1.bath/s31/eh842/public_html/SCR/register/process.php on line 140
> 
> My script, in part, reads as below:
> 
>133   // check to see if company exists in db
>134  
>135     $CompanyQuery = mysql_query("SELECT coid FROM co_details 
>136  WHERE co_name =
>137  '$company' AND co_city = '$city' AND co_country = '$co_country'");
>138  
>139      $CompanyExist = mysql_num_rows($CompanyQuery);
>140      $company_id= mysql_result($CompanyQuery,0,0);
>141  
>142      if ($CompanyExist > 0) {
>143  
>144        //if company exists add workplace details
>145     $confirmkey =  md5(uniqid(rand()));
>146        $signup_id = signup_details($username, $title, $fname, 
> [....]
> 
I have inserted the line numers where I think they are right, please correct
me...

This seems to be a common trivial error: in 139, you get the number of rows
found, but if there are none, you try to retrieve data in line 140, where
you get the error message. Exchange line 140 with 142, and the error message
will go away.

And please, the next time you ask here, post only code snippets (e.g.
beginning of function to 2-5 lines from where you get the error), and
include line numbers. Thanks.

Thomas

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux