Re: Little Problem with my Guestbook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux