...

View Full Version : Not Displaying Query results.



gkelly
06-13-2005, 12:48 PM
<?php
echo "Establishing Connection to Host...<br>";
$db = mysql_connect('localhost','root','') or
die ("Can't connect to database");
echo "Connecting to database.....<br>";
mysql_select_db('perldesk') or
die ("Can't select database");
echo ("Processing Name...........<br>");
$result=mysql_query("select name from perlDesk_users");
while($row = mysql_fetch_array($result));{
echo ($row["name"]);
}
echo "<br>";
mysql_close($db);
echo "Database is now Closed";
It not displaying the information in the Select Statement on the php Page. But when I run the select statment in mysql to query the database it runs fine.

Brandoe85
06-13-2005, 03:45 PM
You have a semi colon after your while loop that shouldn't be there.
while($row = mysql_fetch_array($result));{

gkelly
06-13-2005, 03:52 PM
You have a semi colon after your while loop that shouldn't be there.
while($row = mysql_fetch_array($result));{
Thank You, its fixed

[m] at
06-13-2005, 04:11 PM
You should make use of the "code" and "/code" tags provided by vBulletin. They make it a lot easier for everyone to read code that you've posted.

mr_ego
06-13-2005, 05:01 PM
try mysql_fetch_assoc instead of mysql_fetch_array


http://www.php.net/mysql_fetch_assoc

davehaz
06-13-2005, 09:35 PM
what is the difference in mysql_fetch_assoc and mysql_fetch_array?

Kurashu
06-13-2005, 09:50 PM
mysql_fetch_assoc will dump the results into an associative array by default, but with mysql_fetch_array you need to tell it to do that. Another option is mysql_fetch_object which return the results in an object form.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum