// Save the image to the PHP Database Code
Copy code The Code is as follows: if ($ picture! = "NONE "){
$ Psize = filesize ($ picture );
$ Mysqlpicture = addslashes (fread (fopen ($ picture, "R"), $ psize ));
Mysql_connect ($ host, $ username, $ password) or die ("unable to connect to SQL Server ");
@ Mysql_select_db ($ dB) or die ("unable to select database ");
Mysql_query ("insert into images (image) values ($ mysqlpicture)") or die ("Cant perform query ");
} Else {
Echo "You did not upload any picture ";
}
// Code for reading images in the database using the IMG tagCopy codeThe Code is as follows: mysql_connect ($ host, $ username, $ password) or die ("unable to connect to SQL Server ");
@ Mysql_select_db ($ dB) or die ("unable to select database ");
$ Result = mysql_query ("select * from images") or die ("Cant perform query ");
While ($ ROW = mysql_fetch_object ($ result )){
Echo " picnum "> ";
// The code for the secoed. php file is as follows:
$ Result = mysql_query ("select * from images where picnum = $ picnum") or die ("Cant perform query ");
$ ROW = mysql_fetch_object ($ result );
Header ("Content-Type: image/GIF ");
Echo $ row-> image;