Page 1 of 1

Anyone know why do I get this error? [solved]

Posted: Sun Dec 10, 2006 10:37 pm
by Maluendaster
I just had to add an @ before mysql_fetch_array($result) )

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pablo/public_html/wap/index.php on line 12

Here's the index.php

Code: Select all

<?php

	include 'config.php';
	
	$nu = time();


	$sql = ("SELECT * FROM wapupld_upload");
	$result = mysql_query($sql, $db);				
	$enable = 0;
						
	while($rs = mysql_fetch_array($result) ){ 
		$uptime = $rs["dato"];	
		$idnm = $rs["idnm"];					
		$filname = $rs["filname"];
			
		if(($nu-$uptime) >= $timeallowed) { // slet filen den er udløbet
			
				
				
				unlink("tmpfiles/$filname");
				$sql = ("DELETE FROM wapupld_upload WHERE idnm='$idnm'");
				mysql_query($sql, $db);
				
			
			
			}
					
	
	}


?>


<form enctype='multipart/form-data' action='<?php echo("$urltoindex");?>/uploadfile.php' method='post'> 
<table cellspacing='2' cellpadding='2' border='0'>



<tr>
      <td><p>file: </font></td>
    <td><input name='fil' type='file'></td>
</tr>
<tr>
      <td><p>file size limit: </font></td>
    <td><?php $r = $allowedsize/1024; echo("$r kb");?></td>
</tr>



<tr>
    <td><input name='submit' type='submit' value='Enviar Archivo'> </td>
      <td></td>
	  
</tr>
<input type='hidden' name='from' value='tree'>
</table>
</form>
<?php checklic($license);?>
Also, I get other error, but i don't want to show them and my site, how do i do that?

thanks

Re: Anyone know why do I get this error? [solved]

Posted: Mon Dec 11, 2006 1:48 am
by volka
Maluendaster wrote:I just had to add an @ before mysql_fetch_array($result) )
That only supresses the error message. But still there's something wrong with your script. Try

Code: Select all

$sql = ("SELECT * FROM wapupld_upload");
$result = mysql_query($sql, $db) or die(mysql_error());

Posted: Mon Dec 11, 2006 1:51 am
by Sloth
uhm, I'd try counting the rows too

Code: Select all

$rows = mysql_num_rows($result);
Seems like he's getting an error while retrieve results so it might be a blank array

Posted: Mon Dec 11, 2006 1:58 am
by volka
Sloth wrote:Seems like he's getting an error while retrieve results so it might be a blank array
Yes and no.
mysql_query returns a mysql result resource for an SELECT statement, or FALSE if an error occured. "no records matched the criterias" is not an error, you will only get a result resource with no records attached to.
mysql_fetch_array() expects a result resource. If you pass a FALSE to it you will get the "supplied argument is not a valid MySQL result resource" warning. Same with mysql_num_rows().

Posted: Mon Dec 11, 2006 9:49 am
by Maluendaster
thanks for the replies, i'll try to do it again.