Re: Mysql_fetch_array help from a newbie ...

From: Date: Tue, 04 Jul 2000 13:06:23 +0000
Subject: Re: Mysql_fetch_array help from a newbie ...
Groups: php.general 
Request: Send a blank email to php-general+get-4737@lists.php.net to get a copy of this message
In fact mysql_fetch_array() reveals all the errors that have been coded... Compare your code to this one: <?php $link=mysql_connect("mydbhost","myusername","mydbpassword"); // mydbhost may be "localhost" // If you work locally, myusername and mydbpassword may be omitted (according to the db settings). So the following statement may replace the latter: // $link=mysql_connect("mydbhost"); mysql_select_db("invotti",$link); $query="select * from classi"; $result=mysql_query($query); while ($row=mysql_fetch_array($result) { // $row is now an associative array with the actual result row echo "$row['field1'], "; echo "$row['field2']<br>"; } mysql_close(); ?> Of course you can select the db in every query using mysql_db_query("invotti",$query) instead of selecting the db just once with mysql_select_db() and then accessing tables within this db with mysql_query(). HTH --Steff webmaster@posh.ch www.posh.ch Hya all!! I am jus a newbie, as you know .... Sorry for bothering, but i have written this code: $link = mysql_connect (); $result = mysql_db_query ("invotti","SELECT * FROM classi"); $row = mysql_fetch_array($result); and when i try to access from outside by means of a web browser i get the following error Warning: Supplied argument is not a valid MySQL result resource in /home/httpd/html/webserver01/investimentoottimale/form.php on line 18 the damned worng line is the line $row = mysql_fetch_array($result); the name of the db is invotti, and the name of the table is classi. could be an autorizathion problem?? Let me now, please ... -- Dr. Corrado Topi Responsabile Sezione Progetti Speciali Elbi International S.p.A. - Gruppo Bitron Via De Amicis, 78 10093 Collegno, TO, Italy Ph: + 39 0114102 544 Fax: + 39 0114102 265 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#4737) next »