RE: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread MEM
>On Behalf Of 9el
>

> 

>On Sun, Apr 5, 2009 at 10:08 PM, MEM < 
tal...@gmail.com> wrote:

>Hello,
>
>1)
>Ok, with mysqli, to fetch data from a database to a select drop down list,
we would do something like this >right? :
>$result = $mysqli->query("SELECT id_cliente, nome_cliente FROM cliente");
>echo "";
>
>while($row = mysqli_fetch_assoc($result)) {
>echo "".$row['nome_cliente']."";
>}
>
>echo "";
>?>
>
>2)
>What I’m trying to achieve?
>The same thing, but using PDO, the prepare/execute methods, and FETCH_OBJ
method to fetch data.
>
>3)
>Here is what I have done so far:
>For simplifying I’m just trying to echo:

>
>
>$queryh=$conn->prepare('SELECT id_cliente, nome_cliente FROM cliente');
>$queryh->execute();
>
>/*trys to access the method fetchObject of the PDOStatement generated by
the execute() PDO method, and >save it on $row variable:*/
>$row=$queryh->fetchObject();
>
>/*now I'm trying to echo the results. The 'id_cliente' and 'nome_cliente'
are the column names of my database >and, if I get it right, the
fectchObject() method should allow me to access those names as anonymous
>properties. So: */
>echo "Id: ".$row->id_cliente." - Nome: ".$row->nome_cliente."";
>
>
>4)
>Here is the issue that I’m getting:
>I’m getting no values from the database upon echo request.
>
>
>5)
>Question:
>What is wrong with this code? :(

> 
>There is something definitely wrong with your code. But why did you forget
to use the debugging functions :
>
>print_r()
>and var_dump()  for the results?
>
>So, you'll get some idea beforehand of posting the problem here. I am
looking at the code in a hurry so I cant >help you much right away.
>
>Lenin
>
>www.twitter.com/nine_L

 

 

 

Despite the debug I’m still not getting what’s going wrong. ;( Any help
would be greatly appreciated.

 

 

Regards,

Márcio



Re: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread 9el
>
> Because I’ve never debug on my entire life of programming (2 months). :D
>
> In the meanwhile, I will search how to debug using print_r  and var_dump.
>
> ROFL  ha hahaha

echo '', print_r($array),'';   // here pre is used to
keep the way its outputed in HTML
echo '', var_dump($array),'';

please dont forget to study the online php manual and also the
php_manual.chm version downloaded to your PC.

Its never a good idea to not to debug.


RE: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread MEM
>why did you forget to use the debugging functions :
>
>print_r()
>and var_dump()  for the results?
>
>So, you'll get some idea beforehand of posting the problem here. I am
looking at the code in a hurry so I cant >help you much right away.
>
>Lenin
>
>  www.twitter.com/nine_L

 

 

 

 

Because I've never debug on my entire life of programming (2 months). :D

In the meanwhile, I will search how to debug using print_r  and var_dump.

 

Thanks.



Re: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread 9el
On Sun, Apr 5, 2009 at 10:08 PM, MEM  wrote:

> Hello,
>
> 1)
> Ok, with mysqli, to fetch data from a database to a select drop down list,
> we would do something like this right? :
>  $result = $mysqli->query("SELECT id_cliente, nome_cliente FROM cliente");
> echo "";
>
> while($row = mysqli_fetch_assoc($result)) {
> echo " value=".$row['id_cliente'].">".$row['nome_cliente']."";
> }
>
> echo "";
> ?>
>
> 2)
> What I’m trying to achieve?
> The same thing, but using PDO, the prepare/execute methods, and FETCH_OBJ
> method to fetch data.
>
> 3)
> Here is what I have done so far:
> For simplifying I’m just trying to echo:
>
> $queryh=$conn->prepare('SELECT id_cliente, nome_cliente FROM cliente');
> $queryh->execute();
>
> /*trys to access the method fetchObject of the PDOStatement generated by
> the execute() PDO method, and save it on $row variable:*/
> $row=$queryh->fetchObject();
>
> /*now I'm trying to echo the results. The 'id_cliente' and 'nome_cliente'
> are the column names of my database and, if I get it right, the
> fectchObject() method should allow me to access those names as anonymous
> properties. So: */
> echo "Id: ".$row->id_cliente." - Nome: ".$row->nome_cliente."";
>
>
> 4)
> Here is the issue that I’m getting:
> I’m getting no values from the database upon echo request.
>
>
> 5)
> Question:
> What is wrong with this code? :(
>

There is something definitely wrong with your code. But why did you forget
to use the debugging functions :

print_r()
and var_dump()  for the results?

So, you'll get some idea beforehand of posting the problem here. I am
looking at the code in a hurry so I cant help you much right away.

Lenin

www.twitter.com/nine_L