You are here: Re: newbie problem « PHP SQL « IT news, forums, messages
Re: newbie problem

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация