Jump to content

Warning: round()!


michelt

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.