Php saves the image to the mysql database and displays it on the webpage.
In the php tutorial, save the image to the mysql tutorial database and display it on the webpage.
// Save the image to the database
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 ";
}
// Read images from the database using the img tag
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;