michelt Posted March 11, 2011 Share Posted March 11, 2011 I am trying to output only 40 of the latest files uploaded on the database server. But when I am trying to see the files uploaded on the server I am getting this error: Warning: round() expects parameter 2 to be long, string given in C:\wamp\www\mshare\lista.php on line 8 Call Stack The code: <?php function bytestostring($size, $precision = 0) { $sizes = array('YB', 'ZB', 'EB', 'PB', 'TB', 'GB', 'MB', 'kB', 'B'); $total = count($sizes); while($total-- && $size > 1024) $size /= 1024; return round($size, $precision)." ".$sizes[$total]; } echo '<div class="header">40 last uploaded files:</div>'; $sql = "SELECT * FROM filer order by id desc limit 40"; $q = mysql_query($sql); echo '<table style="width: 100%;">'; while ($r = mysql_fetch_array($q)) { $i++; $id = $r['id']; $filnamn = $r['name']; $filtyp = explode("/", $r['type']); $filtyp = ucwords($filtyp[0]); if($filtyp == "") { $filtyp = "Unkown"; } $filstorlek = bytestostring($r['size'], ""); $a = $i%2; echo'<tr><td class="lista">'; echo ''.$i.'. <td class="lista">'.$filnamn.'<td class="lista">'.$filtyp.' <td class="lista">'.$filstorlek.' <td class="lista"><a href="download.php?id='.$id.'"'.$a.'"><img src="download-icon.jpg" class="imagedow"></a>'; } echo "</table>"; ?> I am new to PHP coding so you guys just know. Link to comment https://forums.phpfreaks.com/topic/230322-warning-round/ Share on other sites More sharing options...
Firemankurt Posted March 11, 2011 Share Posted March 11, 2011 try changing $filstorlek = bytestostring($r['size'], ""); to $filstorlek = bytestostring($r['size'], 0); or $filstorlek = bytestostring($r['size']); Link to comment https://forums.phpfreaks.com/topic/230322-warning-round/#findComment-1186125 Share on other sites More sharing options...
michelt Posted March 11, 2011 Author Share Posted March 11, 2011 try changing $filstorlek = bytestostring($r['size'], ""); to $filstorlek = bytestostring($r['size'], 0); or $filstorlek = bytestostring($r['size']); Nope, that does not solve the problem :/ Link to comment https://forums.phpfreaks.com/topic/230322-warning-round/#findComment-1186166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.