Warning: mysql_fetch_array(): supplied argument (ERROR)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Warning: mysql_fetch_array(): supplied argument (ERROR)

Post by robster »

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/edited_location_of_files/index_welcome.php on line 6


This is very strange as It works just fine at home on my Win2K server setup, but when I upload my code to the Redhat linux server setup I get this error. I CAN see a lot of my database stuff, but not some of it and the stuff I can't see all gives this error.

Does anyone have any suggestions as to what it might be?

Here is the code it's erroring on:

Code: Select all

<?
    print "  <td bgcolor="$hBGcolor" valign="top" colspan="2">";
    print "  <div align="$hAlignment"><font size="$hSize" face="$hFont"><b><font color="$hColor">";

	$content = mysql_db_query($dbname, "SELECT * FROM welcome_message");
	$Xcontent = mysql_fetch_array($content);

	$subject = $Xcontent["subject"];
	$message = $Xcontent["message"];

	Print "$subject";
	print "	 </font></b></font></div>";
    	print "</td>";
  	print "</tr>";
     
        print "<tr>";
        print "<td valign="top">";
	Print "$message";
	print "</td>";
?>
Thanks LOADS in advance...

Rob
Last edited by robster on Mon Jul 21, 2003 5:03 pm, edited 1 time in total.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

first, your problem si that your query is not returning anything

second, what if your "select * ..." return more than 1 record?

think about it (foreach...)
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

Thanks for the reply.

What I don't understand is it worked until today.. .How strange.

Also, you say it doesn't return anything... I'm REALLY a newby here so forgive my ignorance, but wouldn't it return EVERYTHIING (*) from the table (welcome_message)?

There is only one record in this particular example. A simple welcome message.

I'm sorry, i just don't fully understand, could you (or anyone) possible show me how it should look?

Thanks :)

rob
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

What do you want to display? The last message?
if you want to do that, just cut your select witha WHERE or a LIMIT and retreive only one record
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

I'm sorry to sound vague...

I have the table called "welcome_message"
It contains the fields "ID" "event" "subject" "message"

-ID is just that
-event is the date
-subject is the actual welcome message title
-message is the actual welcome message

There is only one record.

I want to display the "subject" and the "message" fields.
The code that calls this snippet of code has handled that in the past, I just don't know what's going wrong today.. And if it IS wrong, why has it worked for the last week and now stopped working (also doesn't work on the home windows server also!).

So frustrating...


Also, and I don't mean to sound ungrateful, I really appreciate your help, but I don't quite understand what you mean by just cut your select witha WHERE or a LIMIT and retreive only one record?

Could you perhaps explain a little more....?

Thanks :)
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

ok, now I feel stupid... The reason it wasn't working is I didn't have my

<?
require("config.php");
?>

which contains all my database info etc... I just am going to go and hide now....
Post Reply