954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Hello,

I created this site on my local machine using PHP 5.0.4 and mysql 4.1 and it works perfectly fine.

I then ftp it to my webhost but the code to retrieve values give me this error.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/laterallinks/ApplicantInformation.php on line 25

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/www/laterallinks/ApplicantInformation.php on line 621

I let my webhost know they so they upgrade from php 4 to php 5.0.5 but still use mysql client version 3.x

Here is the portion of the code that uses the functions.

segment 1:

$sql = mysql_query($query);

while($row = mysql_fetch_array($sql)){
?>

Time of Application: <? echo $row['dateApplied']?>



segment 2:

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM applicants ". $genQuery),0);


what could be possible wrong.

iketunde
Newbie Poster
13 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

It's probably not a php version problem

usually $sql and $query are the same thing and you use $result for the result set. That improves readability but doesn't fix anything

$result = mysql_query($query) or die(mysql_error() . ''. $query);
     
while($row = mysql_fetch_array($result)){
 var_dump($row);
}


this should show where the problem is.

If it's the query paste it into phpMyAdmin and see the errors there. It may be something simple like a missed quote mark or a column in the table.

Sarah

sarahk
Junior Poster
144 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

Sarah,

Thank so very much. but how can i be having problems online when the code works perfectly on my test machine.

iketunde
Newbie Poster
13 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

That points to a connection issue - but also to a potential difference in the structure of the tables. I was hoping the error message would give you one of those moments when you go "d'oh". It's frustrating but a solution is always a good thing.

We really need to know what mysql_error() returns.

sarahk
Junior Poster
144 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

Sarah...

thank u.. it worked. the its a case sensitive issue. i named the table Applicants and it refered to it as applicants;

thanks once more

iketunde
Newbie Poster
13 posts since Oct 2005
Reputation Points: 10
Solved Threads: 0
 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource


code is here>>>>
$query = "SELECT * FROM upload_question_1 ORDER BY Rand() WHERE

exprience='".$expr."' AND gread='".$catg."' LIMIT 1";


$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
//echo "$row[0]$row[1]$row[2]

";
echo $row [1];

visagar
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You