|
Posted by Rik on 08/07/06 13:24
tony wrote:
> Hi guys
> I'm new to PHP and I'm trying the following:
>
> <?php
> mysqli_connect ("localhost","root","mypassword",);
> mysqli_select_db (mads);
> $result=mysqli_query (SELECT * FROM clients);
>
> print ($result);
>>
>
> According to me (no great authority I know) this should print the
> array from the clients table. I can execute the query from the
> command line and it works fine. However, when I try to run the script
> nothing happens. I've tried everything I can think of-PHP, Mysql and
> Apache are all working (I can use PHPmyAdmin).
>
> I must be doing something wrong. What is it?
1. mysqli_select_db (mads); should be mysqli_select_db ('mads');
2. $result is a resource, not a string or array.
3. Only strings & numbers can be printed.
Use mysqli_fetch_assoc($result) after your query, normally something like
this:
while($row = mysqli_fetch_assoc($result)){
print(implode(',',$row));
}
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|