I didn't notice much wrong with your English. Where are you from?
Also, in resopnse to:
<<<<< need some code to convert image $image_p to string because echo "$image_p"; give some like "Resourse #6>>>>>>
you need to output the image in an image format. A common example is the "JPEG" format, which appears to be what you're using. To do this, change:
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
$query = "INSERT into filebin (BType, BDesc, BBinary) VALUES ('$type', '$note', '$image_p')";
to:
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
ob_start();
imagejpeg($image_p, '', 100);
$image_string = ob_get_contents();
ob_end_clean();
$query = "INSERT into filebin (BType, BDesc, BBinary) VALUES ('$type', '$note', '$image_string')";
What I did in the above code was turn on Output Buffering, use imagejpeg() to output a jpeg image from the image resource, grab the data that WOULD have been sent to the user's browser and store it in $image_string, then destroy the buffer and turn off Output Buffering.
There may be a simpler way, but this is what I came up with.
In response to your second question, you obviously don't know what HTTP Headers do exactly. A header is sent BEFORE the document; it tells the browser a little bit about the document. You can't just start sending an image header in the middle of a document and expect the browser to create an image out of it.
Instead, you need to make the browser EXPLICITY request the image, so that you can EXPLICITY send the image header and output the image data. In short, link to your image script like:
<img src="my_image_script.php">
Now you can create a script (or link to the same script, but use something like "action=image" so that you can send JUST the image data/headers) that contains the headers/image output you have in your code.
EDIT:
This topic has been covered many times. Please do a search. I think it's in the FAQ.
Also, this is NOT the best way to manage images -- IMHO. Save the image files on your server, and store the path to the image in the database, not the image itself.
I agree 100%. I figured there was some reason he was storing images in the MySQL DB. I find it terribly messy transferring images via strings into a DB, and reversing the same process to output them.
Instead, why can't you resize the images, and save them in a folder? I suppose if you wanted to catalog information about the images, you could instead store the image filename along with your data. You can then use functions such as [man]readdir[/man] (see my post here that uses [man]scandir[/man] with backwards compatibility for PHP 4) to retrieve an array of filenames from your "image" directory. Use a foreach() to loop through the array, retrieving data from MySQL as necessary.