Hi,
change line 170 to this:
$form_category_id[$i] = mysql_result($result_category_id, 0, 0);

In each iteration your program executes new SQL query, which
selects only one column from table, and i think, it selects only one row
too. So you have to select first column from first row. With your
code: mysql_result($result_category_id, 0, $i); you try to get value
from first row but from columns 1,2,3,4,5... etc. as for runs through
array. 

Hope this helps.

Petr Tomenendal.




On Wed, 2002-10-02 at 18:57, Wilmar Perez wrote:
> Hello guys.
> 
> The scenery:  I've got an array with some values stored in it.  I want to 
> retrieve the id code each value is associated to.  So I just do the following:
> 
> for ($i=0; $i<count($form_category);$i++)
> {
> $query_get_id = "select cat_code from categories 
>                where cat_name like '$form_category[$i]'";
> $result_category_id = mysql_query($query_get_id) or die(mysql_error());
> $form_category_id[$i] = mysql_result($result_category_id, 0, $i); //This
>                                                                   is line
>                                                                   170
> echo $form_category[$i]." ".$form_category_id[$i]."<br>";
> }
> 
> I'm getting the following in my browser  (There are some comments I just 
> added):
> 
> Arquitectura 2  //This is the correct category name and its ID
> 
> Warning: Bad column offset specified 
> in /var/www/bva/new/common/scripts/admin_functions.php on line 170
> Caricatura     //This is the correct category name but the ID is lost
> 
> Warning: Bad column offset specified 
> in /var/www/bva/new/common/scripts/admin_functions.php on line 170
> Ciencias naturales //Same as before
> 
> Any idea of what I'm doing wrong?
> 
> *******************************************************
>                          Wilmar Pérez
>                      Network Administrator
>                        Library System
>                       Tel: ++57(4)2105145
>                     University of Antioquia
>                        Medellín - Colombia
>                               2002    
> *******************************************************                
>  
>          
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



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

Reply via email to