Note that there are some explanatory texts on larger screens.

plurals
  1. POImage not showing (broken image) but search works
    text
    copied!<p>i'm new in programming and have been working on a searchable database which can retrieve images by typing in keywords and after pressing submit will show results and the picture.</p> <p>But so far i have no luck in getting the picture to show(broken link/image) but my search form does work and does correctly retrieve the name or result.</p> <p>My table in phpmyadmin name is <strong>shoes</strong> , and i have 3 columns, 1 id (int15 PRI) ,2 brand/model (varchar 50), 3 picture (longblob).</p> <p>My code is relative simple and hope you can help me out =)</p> <p><strong>File name: search.php</strong></p> <pre><code>&lt;form action="search.php" method="POST"&gt; Name: &lt;input type ="text" name="search_name"&gt; &lt;input type="submit" value="Search"&gt; &lt;?php if (isset($_POST['search_name'])) { $search_name = $_POST['search_name']; if (!empty($search_name)){ if (strlen($search_name)&gt;=3) { $query = "SELECT * FROM `shoes` WHERE `brand/model` LIKE '%".mysql_real_escape_string($search_name)."%'"; $query_run = mysql_query($query); $query_num_rows = mysql_num_rows($query_run); if ($query_num_rows&gt;=1) { echo $query_num_rows.' Results found:&lt;br&gt;'; while ($query_row = mysql_fetch_array($query_run)) { $picture = $query_row['picture']; echo "&lt;/br&gt;"; echo $query_row ['brand/model']; echo "&lt;/br&gt;"; echo "&lt;/br&gt;"; //header("content-type: image/jpeg"); echo "&lt;img src=image.php?id=".$row['id']." width=300 height=200/&gt;"; echo "&lt;/br&gt;"; } } else { echo 'No Results Found.'; } } else { echo 'Text field must be more than 3 characters.'; } } else { echo 'Text Field Cannot be Empty!'; } } ?&gt; </code></pre> <p><strong>i have a image.php here</strong></p> <pre><code>&lt;?php ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysql_connect("localhost","root",""); if(!$conn){ echo mysql_error(); } $db = mysql_select_db("phsdatabase"); if(!$db){ echo mysql_error(); } $id = $_GET['id']; $query = "SELECT `picture` FROM shoes where id='$id'"; $query_run = mysql_query("$query",$conn); if($query_run){ $row = mysql_fetch_array($query_run); $type = "Content-type: image/jpeg"; header($type); echo $row['picture']; } else { echo mysql_error(); } </code></pre> <p>?></p> <p><strong>storeinfo.php</strong> to store new info,</p> <pre><code>&lt;?php ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysql_connect("localhost","root",""); if(!$conn) { echo mysql_error(); } $db = mysql_select_db("phsdatabase",$conn); if(!$db) { echo mysql_error(); } @$brandmodel = $_POST['brand/model']; @$picture = addslashes (file_get_contents($_FILES['picture']['tmp_name'])); @$image = getimagesize($_FILES['picture']['tmp_name']);//to know about image type etc //$imgtype = $image['mime']; if (isset($_POST['brand/model'])){ $brandmodelentry = $_POST['brand/model']; if (!empty($brandmodelentry)){ if (strlen($brandmodelentry)&gt;=3) { $query ="INSERT INTO shoes VALUES('','$brandmodel','$picture')"; $query_run = mysql_query($query,$conn); echo '&lt;br&gt;'; echo "Information Stored Successfully!"; } else { echo mysql_error(); } echo '&lt;br&gt;'; echo '&lt;br&gt;'; echo "Thank you for Registering new information to our database!"; } else{ echo 'Text Field cannot be empty!'; } } </code></pre> <p>?></p> <p><strong>newentry.php which register new info</strong> </p> <pre><code>&lt;form enctype="multipart/form-data" action="storeinfo.php" method="POST"&gt; &lt;center&gt;Shoes Information&lt;/center&gt; Brand and Model Name&lt;input type=text name="brand/model"&gt; Picture of Shoes(Acceptable formats:&lt;br&gt;JPEG,JPG,PNG)&lt;input type="file" name="picture" id ="picture"&gt; &lt;input type=submit name="submit" value="Store Information"&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload