Showing Image from mysql database in custom size

Hello coders, Now we will discuss about a great feature of PHP and mySql. Sometime we have problem  using images stored in database in custom size. The function bellow will destroy that problem.
function getImage($id, $width, $height)
$link=mysql_connect("hostname","username","password") or die("can't connect to server");
mysql_select_db("dbname",$link) or die("Can't connect to database");

$sql="Select `Photo` from `Phototable` where `ID`='$id'";
$bytes = $row["Photo"];
$instr = fopen("default.jpg","rb");
$bytes = fread($instr,filesize("default.jgp"));

$data = base64_encode($bytes);

echo '';

1 comment:

Communicate with Authore