Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   MYSQL output help (http://www.programmingforums.org/showthread.php?t=11227)

kruptof Aug 31st, 2006 4:33 PM

MYSQL output help
 
Quote:

<?
mysql_connect(xxxxxxxxx,'xxxxxxxx','xxxxxxxx')||die("Error Connecting to server");

mysql_select_db("db")||die("Error Connecting to database");

$result=mysql_query("select event from events")||die("error querying db");
echo $result[0];
#$cont=mysql_fetch_array($result);
?>
i can't seem to get this working..........when i run it nothing is ouputted when i try to use the fetch array function i get an error that i supplied an argument that is not an array.....i got values inside the db...any help please.

Ooble Aug 31st, 2006 6:50 PM

[php]$result=mysql_query("select event from events")||die("error querying db");
$row = mysql_fetch_row($result);
echo $row[0];[/php]

Enjoy. :)

Jimbo Aug 31st, 2006 6:51 PM

$result is not an array. It is a MySQL resource, assuming the query was successful (if it wasn't, you'd get the call to die()). After the call to mysql_fetch_array(), $cont should be an array containing something to the likes of Array("event" => /*whatever an event would be*/). You can call mysql_fetch_array($result) as many times as rows were returned from the query (mysql_num_rows($result)).


All times are GMT -5. The time now is 1:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC