Can't get an image to load to a webpage using PHP with MySQl -
I have a few questions to answer. It is for the first time that when I loggedin.php
If I log in to the page, then I can not do to populate images from MySQL. I'm getting a broken link. I have seen people ask this question, but I have done my page in such a way that when I saw it, I can not do it to work properly.
$ UpdateQuery
, I am not able to convert the image at all. I have seen it all around and whatever I found was a YouTube video that did not actually help me. Thanks in advance.
& lt ;! DOCTYPE html & gt; & Lt; Top & gt; & Lt; Html & gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt ;! - Latest compiled and minimal CSS dragged from bootstrap - & gt; & Lt; Link rel = "stylesheet" href = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" & gt; & Lt ;! - Optional topics pulled from bootstrap - & gt; & Lt; Link rel = "stylesheet" href = "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" & gt; & Lt ;! - Personal Sylesheet - & gt; & Lt; Link href = "MandelsCSS.css" rel = "stylesheet" type = "text / css" & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;! - Form to add new images to the database - & gt; & Lt; Div class = "wrapper" & gt; & Lt; H1 align = "center" & gt; Add image & lt; / H1> & Lt; Form class = "form-signin" action = "loggedin.php" method = "post" & gt; Image name: & lt; Input class = "form-control" type = "text" name = "name" & gt; & Lt; Br / & gt; Image details: & lt; Input class = "form-control" type = "text" name = "description" & gt; & Lt; Br / & gt; Image: & lt; Input class = "BTN BTN-LG BTN-Default BTN-Block" type = "file" name = "picture" & gt; & Lt; Br / & gt; & Lt; Input class = "BTN BTN-LG BTN-default BTN-block" type = "submit" name = "submit" value = "insert new image" & gt; & Lt; / Form & gt; & Lt; Br> & Lt; Br> & Lt; Br> & Lt; H1 align = "center" & gt; Update images & lt; / H1> & Lt ;! - To add new images to DB - PHP - & gt; & Lt ;? Php is required ("connect1.php"); Ob_start (); Session_start (); Select $ = "Select from images"; $ MyData = mysqli_query ($ connect, choose $); Value ('$ _ POST [image]', '$ _ POST [name]', '$ _ POST [INFO] ($ $ _ POST [' submit '])'] '; MySqli_query ($ connect, $ Sql);}};? Gt; php $ select = "select from pictures"; $ MyData = mysqli_query ($ connect, select $); while ($ record = mysqli_fetch_array ($ myData)) {? & Gt; & lt; form class = "form-signin" action = "loggedin.php" method = "post" & gt; image name: & lt; input class = "form-control" type = "text" name = " Name "value = & lt ;? php echo $ record ['image_name']? & Gt; & gt; & lt; br / & gt; Image description: & lt; input class =" form-control "type =" text "Name =" description "value = & lt ;? php echo $ record ['description']? & Gt; & gt; & lt; br / & gt; Image: & lt; input class = "form-control" type = "file" name = "image" & lt ;? php echo $ record ['image']? & Gt; & gt; & lt; img name = " Image "src = & lt ;? Php resonance $ record ['image']? & Gt; & gt; Input class =" form-control "type =" hidden "name =" hidden "value = & lt ;? Php echo $ record ['image_name']? & Gt; & gt; & Lt; Input class = "BTN BTN-LG BTN-default BTN-block" type = "submit" name = "update" value = "update information" & gt; & Lt; Input class = "btn btn-LG btn-default btn-block" type = "submit" name = "delete" value = "delete" & gt; & Lt; / Form & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt ;? Php if (isset ($ _ POST ['update'])) {$ imageName = mysqli_real_escape_string ($ connect, $ _FILES ["image"] ["name"]); $ ImageData = mysqli_real_escape_string ($ connect, file_get_contents ($ _ files ["image"] ["tmp_name"])); Echo $ ImageData; $ UpdateQuery = "Update image SET image_name = '$ _ POST [name]', image = '$ _FILES [image]', description = '$ _ POST [description]' WHERE image_name = '$ _ POST [hidden] '"; Mysqli_query ($ connect, $ UpdateQuery); } If (isset ($ _ POST ['delete'])) {$ DeleteQuery = "Remove images from image_name = '$ _ POST [hide]' 'MySqli_query ($ connect, $ DeleteQuery);}} Mysqli_close ($ Connect ); Post-text "itemprop =" text "> You can not add a photo to image = '$ _FILES [image]'
! move_uploaded_file ($ file, $ Targetpath)
and save the image name in DB!
Comments
Post a Comment