|
Posted by tony on 08/07/06 14:54
Rik wrote:
> 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,
Thanx for the reply Rik, unfortunatley that didn't work.
I tried to step back a step and try the following:
<?php
print ('hey there');
mysqli_connect ("localhost","root","Xtasy66");
mysqli_select_db ('mads');
$result=mysqli_query(SELECT * FROM clients);
?>
When I execute the first 3 lines I get "hey there". However, when I add
the last line I get nothing. My conclusion is there's somthing wrong
with this line. The only problem is I can't see what it is.
Can you help?
thanx
Navigation:
[Reply to this message]
|