User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2005
Posts: 13
Reputation: iketunde is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
iketunde iketunde is offline Offline
Newbie Poster

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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation: sarahk is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

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

$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
Reply With Quote  
Join Date: Oct 2005
Posts: 13
Reputation: iketunde is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
iketunde iketunde is offline Offline
Newbie Poster

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

  #3  
Oct 17th, 2005
Sarah,

Thank so very much. but how can i be having problems online when the code works perfectly on my test machine.
Last edited by iketunde : Oct 17th, 2005 at 5:22 am. Reason: typo error
Reply With Quote  
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation: sarahk is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

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.
Reply With Quote  
Join Date: Oct 2005
Posts: 13
Reputation: iketunde is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
iketunde iketunde is offline Offline
Newbie Poster

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

  #5  
Oct 17th, 2005
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
Reply With Quote  
Join Date: Mar 2008
Posts: 1
Reputation: visagar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
visagar visagar is offline Offline
Newbie Poster

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];
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC