Page 1 of 1

Warning: mysql_fetch_array(): supplied argument (ERROR)

Posted: Mon Jul 21, 2003 4:01 pm
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

Posted: Mon Jul 21, 2003 4:19 pm
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...)

Posted: Mon Jul 21, 2003 4:39 pm
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

Posted: Mon Jul 21, 2003 4:45 pm
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

Posted: Mon Jul 21, 2003 5:02 pm
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 :)

Posted: Mon Jul 21, 2003 5:19 pm
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....