Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 31st, 2006, 3:33 PM   #1
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 329
Rep Power: 3 kruptof is on a distinguished road
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.
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Aug 31st, 2006, 5:50 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
[php]$result=mysql_query("select event from events")||die("error querying db");
$row = mysql_fetch_row($result);
echo $row[0];[/php]

Enjoy.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 31st, 2006, 5:51 PM   #3
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 751
Rep Power: 3 Jimbo is on a distinguished road
$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)).
Jimbo is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change the name of output file jazz C 4 Jun 28th, 2006 2:54 AM
MySQL with python? snipertomcat Python 2 Apr 13th, 2006 1:34 AM
Numerical data output to a file can342man C++ 4 Jan 27th, 2006 4:21 PM
Tutorial - Using MySQL in C# Darkhack C# 12 Jan 17th, 2006 9:28 AM
It's giving me "Press any key to continue" and no other output.. Insomniac C 15 Jun 5th, 2005 7:07 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:33 PM.

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