•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 392,063 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,251 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 8818 | Replies: 5
![]() |
•
•
Join Date: Oct 2005
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 0
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
#1
Oct 16th, 2005
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['dateApplied']?></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.
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['dateApplied']?></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.
•
•
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation:
Rep Power: 4
Solved Threads: 1
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resou
#2
Oct 17th, 2005
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
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
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
•
•
Join Date: Oct 2005
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 0
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
#3
Oct 17th, 2005
•
•
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation:
Rep Power: 4
Solved Threads: 1
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
#4
Oct 17th, 2005
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.
We really need to know what mysql_error() returns.
•
•
Join Date: Oct 2005
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 0
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
#5
Oct 17th, 2005
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Re: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
#6
Mar 17th, 2008
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];
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];
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource (PHP)
- mysql_num_rows(): supplied argument is not a valid MySQL result resource in /user/690 (PHP)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
Other Threads in the PHP Forum
- Previous Thread: echo when pushing button
- Next Thread: datagrid working but php_self problem


Linear Mode