Re: newbie question: fetchrow or smth else ?
| From: | Alecs | Date: | Fri, 01 Feb 2002 10:16:22 +0000 |
| Subject: | Re: newbie question: fetchrow or smth else ? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16393@lists.php.net to get a copy of this message | ||
okay, thanks for help ;-p
fetchrow failed because my query was buggy, the proper syntax for left is
LEFT(something, number)
"Alecs" <r3ddr@yahoo.com> wrote in message
news:20020201085131.9073.qmail@pb1.pair.com...
>
> Could some one please check the following code and guesstimate where am I
> wrong ?
> (the only thing I got from browser is: Fatal error: Call to undefined
> function: fetchrow() pc_list.php on line 14, but on that line I have
> fetchRow() not fetchrow(). To make it worse even when I am replacing
> fetchRow() with FetchRow the same error is reported)
>
> PS. I used PEAR that comes with php-4.1.1 and php-4.0.4pl1. nothing
changed
> :(
>
> ---
> require_once "DB.php" ;
>
> $db = DB::connect("$db_type://$db_user:$db_pass@$db_host/$db_name",
> $db_pipe) ;
> $req = "SELECT pc.hostname, m.logo, pc.mac, pc.ip FROM computer pc, mac m
> WHERE m.id = LEFT(pc.mac) " ;
>
> $p_req = $db->prepare($req) ;
> $res = $db->execute($p_req) ;
>
> echo " <table border=1> \n" ;
> echo " <tr> <th> Hostname </th> <th> Logo </th> <th>
> MAC </th> <th> IP
> </th>
> </tr>\n" ;
>
> $counter = 0 ;
> while ( $arr=$res->fetchRow() ) {
> echo " <tr> <td> $arr[0] </td> <td> <img
> src=\"logos/$arr[1]\">
> </td> " ;
> echo " <td> $arr[2] </td> <td> $arr[3] </td> </tr>
> \n" ;
> $counter++ ;
> }
>
>
>