Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
I get this error when trying to display info from my database
Old 04-18-2009, 07:40 PM I get this error when trying to display info from my database
Extreme Talker

Posts: 176
Name: Aaric
Trades: 0
I am new to PHP/MYSQL but I've done a little. I am actually using code that worked on a different site of mine but I can't seem to get info from the database now. I am able to use a form to add info but when trying to display it I get an error.

I get this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/vqtkkzap/public_html/may30/confirmed/display.php on line 14

The code on line 14 it references is this:

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

I am not sure what I am doing wrong. Can anyone help?
aaricwon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-18-2009, 07:49 PM Re: I get this error when trying to display info from my database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
This errors means that you either heven't fired the sql query with mysql_query(), or that there was an error when you did.

Check the query result with something like
PHP Code:
$result=mysql_query($query);
if (
$result === FALSE){
  print 
mysql_error();
  die();

__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-18-2009, 07:52 PM Re: I get this error when trying to display info from my database
Extreme Talker

Posts: 176
Name: Aaric
Trades: 0
I put that code in there and get this: No database selected
aaricwon is offline
Reply With Quote
View Public Profile
 
Old 04-19-2009, 07:27 AM Re: I get this error when trying to display info from my database
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
So, select a database after connecting to the server.
http://www.php.net/manual/en/functio...-select-db.php
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 04-20-2009, 12:58 PM Re: I get this error when trying to display info from my database
Novice Talker

Posts: 12
Trades: 0
i like doing

$result=mysql_query($query) or die ("Mysql Error - " . mysql_error());

that way if i screw up.... the site slaps me in the face

anyway looks liek your missing

mysql_select_db("your database name");
__________________
Reliable and Legal
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
?
Find A Paralegal Fast.

Please login or register to view this content. Registration is FREE
sjenkins is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to I get this error when trying to display info from my database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37481 seconds with 12 queries