PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Maluendaster
Forum Contributor
Posts: 124 Joined: Fri Feb 25, 2005 1:14 pm
Post
by Maluendaster » Sun Dec 10, 2006 10:37 pm
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
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Dec 11, 2006 1:48 am
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());
Sloth
Forum Newbie
Posts: 18 Joined: Thu Dec 07, 2006 7:29 pm
Post
by Sloth » Mon Dec 11, 2006 1:51 am
uhm, I'd try counting the rows too
Seems like he's getting an error while retrieve results so it might be a blank array
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Dec 11, 2006 1:58 am
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().
Maluendaster
Forum Contributor
Posts: 124 Joined: Fri Feb 25, 2005 1:14 pm
Post
by Maluendaster » Mon Dec 11, 2006 9:49 am
thanks for the replies, i'll try to do it again.