Re: Little Problem with my Guestbook
| From: | John Nichel | Date: | Wed, 14 Sep 2005 13:45:30 +0000 |
| Subject: | Re: Little Problem with my Guestbook | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222389@lists.php.net to get a copy of this message | ||
Florian P. wrote:
<?php include("sql.inc.php"); include("config.inc.php"); $connection = mysql_connect($sql['host'],$sql['uid'],$sql['pwd']); $select_db = mysql_select_db($sql['db']); $select = mysql_query('SELECT * FROM comments'); $data = mysql_fetch_array($select); $result = mysql_query('SELECT * FROM comments'); $rows = mysql_num_rows($result); <snip>No reason to run this twice.... $data = array(); if ( $result = mysql_query ( 'SELECT * FROM comments' ) ) { while ( $temp = mysql_fetch_array ( $result, MYSQL_ASSOC ) ) { $data[] = $temp; } $rows = mysql_num_rows ( $result ); mysql_free_result ( $result ); } else { echo ( mysql_error() ); exit; } The returned rows will be in the $data array. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com