Re: Problem with my first script

From: Date: Wed, 25 Jul 2001 13:15:47 +0000
Subject: Re: Problem with my first script
Groups: php.db 
Request: Send a blank email to php-db+get-10746@lists.php.net to get a copy of this message
Hi, you shoud use $myrow[field_name] instead of $myrow(field_name). Notice the brackets. As long $myrow is an array $myrow() points to a function array() which ends up with error. Dobromir Velev -----Original Message----- From: Fernando Gonzalez <fergonza@terra.com.pe> To: leo g. divinagracia iii <ldivinag@csuhayward.edu> Cc: php-db@lists.php.net <php-db@lists.php.net> Date: Wednesday, July 25, 2001 5:23 AM Subject: RE: [PHP-DB] Problem with my first script >Thanks, but it wont work. >I have eliminate the space but still the same message. >I have realized that the problem is below that line: >the problem is pointing to the line where i fetch the first variable: >$nombre=$myrow("nombre"); > >Any other Ideas???? >thanks > ><? >echo "Resultados de tabla Empresas"; >echo"<br>"; > $link = mysql_connect ("localhost:3306", "root", "") > or die ("Could not connect"); > print ("Connected successfully"); > >mysql_select_db ("seguros"); >$sql="select * from mae_companias"; >$result=mysql_query($sql,$link); >echo "<table >align='center'><tr><td></td>Nombre<td>Direccion</td><td>Telefono</td><td>Fa x ></td>"; > >$num=mysql_num_rows($result); >$cur=1; >while($num>=$cur){ >$myrow=mysql_fetch_array ($result); > >$nombre=$myrow("nombre"); >$direccion=$myrow("direccion"); >$telefono=$myrow("telefono"); >$fax=$myrow("fax"); >echo > > "<tr><td>$nombre</td><td>$direccion</td><td>$telefono</td><td>$fax</td>"; > $cur++; >} >echo "</table>"; >?> > > > > > >----- Original Message ----- >From: leo g. divinagracia iii <ldivinag@csuhayward.edu> >Cc: <php-db@lists.php.net> >Sent: Tuesday, July 24, 2001 7:52 PM >Subject: Re: [PHP-DB] Problem with my first script > > >> i havent tested it yet... but... >> >> Fernando Gonzalez wrote: >> > >> >> > $num=mysql_num_rows($result); >> > $cur=1; >> > while($num>=$cur){ >> > $myrow=mysql_fetch_array ($result); >> ^^ >> >> you got a space after the function and the open paren. NO SPACES!!!! >> (as i found before that took about 10 minutes of debugging on a similar >> debugging session...) ;-))) >> >> >> -- >> Leo G. Divinagracia III >> ldivinag@csuhayward.edu >> >> -- >> PHP Database Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net >> For additional commands, e-mail: php-db-help@lists.php.net >> To contact the list administrators, e-mail: php-list-admin@lists.php.net >> > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net >For additional commands, e-mail: php-db-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#10746) next »