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)){
?>
<div align="center">



<p align="right"><font face="Courier New"><font color="#0000FF"><b>Time of Application: </b></font> <? echo $row?></font></p>
<table border="1" width= "750" style="border-collapse: collapse" id="table1" bgcolor="#F2FDFF">


segment 2:


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

what could be possible wrong.

Edited 3 Years Ago by happygeek: fixed formatting

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() . '<br />'. $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

Sarah,

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

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.

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

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 "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]


</td></tr>";
echo $row [1];

Edited 3 Years Ago by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.