scaleautostyle Posted July 3, 2010 Share Posted July 3, 2010 now the search function is working good. but the image show is blank with an X at the top left corner... WHY??? this is my code <?php include_once("db_connection.php"); if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){ $name=$_POST['name']; //-query the database table $sql="SELECT kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, engine_detail, year_prod_kit, year_prod_reel, scale, image_id FROM kit WHERE kit_name LIKE '%" . $name ."%' OR description LIKE '%" . $name . "%' OR manufacturer_kit LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $description =$row['description']; $manufacturer_kit=$row['manufacturer_kit']; $kit_id=$row['kit_id']; $kit_number=$row['kit_number']; $kit_name=$row['kit_name']; $engine_detail=$row['engine_detail']; $year_prod_kit=$row['year_prod_kit']; $scale=$row['scale']; $image_id=$row['image_id']; //-display the result of the array echo "<ul>\n"; echo "<li>" .$kit_number . " " . $manufacturer_kit . " " . $kit_name . " " . $description . " " . $year_prod_kit . " " . $engine_detail . " " . $scale . " </li>\n"; echo "<img src='picture/".$image_id['imgage_id']."' width='150' height='100'/>"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } } ?> if I made a property on the blank image this is what it return me as path.... .............../picture/h where the h come from???? thanks for your help sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/ Share on other sites More sharing options...
ToonMariner Posted July 3, 2010 Share Posted July 3, 2010 probably because you have the path to image wrong. the image tage takes the url (relative or absolute) to the actual image file - so unless you are using a dynamic image creation script the src attribute should contain the path and file name of the image. /picture/h - clearly this is is missing the extension! Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080683 Share on other sites More sharing options...
PFMaBiSmAd Posted July 3, 2010 Share Posted July 3, 2010 $image_id=$row['image_id']; ^^^ You are setting $image_id equal to $row['image_id'] in your code. You would either need to use $image_id in the src='...' attribute or use $row['image_id']. Why are you using $image_id['imgage_id']? Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080697 Share on other sites More sharing options...
scaleautostyle Posted July 3, 2010 Author Share Posted July 3, 2010 probably because you have the path to image wrong. ........... /picture/h - clearly this is is missing the extension! the thing is... I don't know where come the h I don't have any images starting with an h ?????? yours sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080853 Share on other sites More sharing options...
scaleautostyle Posted July 3, 2010 Author Share Posted July 3, 2010 ............. Why are you using $image_id['imgage_id']? because Image_id is one of my field in my database where my image are stock. thanks for any advice sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080855 Share on other sites More sharing options...
scaleautostyle Posted July 3, 2010 Author Share Posted July 3, 2010 the thing that I can see it's.. the h came from the path put in the field. I just change one for the dirct link and now it's mark a t because the file name is tam2401.jpg #%$%#% now how can I get the full name instead of just the frst letter thanks in advance yours sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080861 Share on other sites More sharing options...
PFMaBiSmAd Posted July 3, 2010 Share Posted July 3, 2010 now how can I get the full name instead of just the first letter By using the correct variable that is holding the file name, like someone told you above ... Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080864 Share on other sites More sharing options...
scaleautostyle Posted July 3, 2010 Author Share Posted July 3, 2010 it's done this is my code corrected. <?php include_once("db_connection.php"); if(isset($_POST['submit'])){ if(isset($_GET['go'])){ if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){ $name=$_POST['name']; //-query the database table $sql="SELECT kit_id, kit_number, kit_name, description, manufacturer_kit, manufacturer_reel, engine_detail, year_prod_kit, year_prod_reel, scale, image_id FROM kit WHERE kit_name LIKE '%" . $name ."%' OR description LIKE '%" . $name . "%' OR manufacturer_kit LIKE '%" . $name ."%'"; //-run the query against the mysql query function $result=mysql_query($sql); //-create while loop and loop through result set while($row=mysql_fetch_array($result)){ $description =$row['description']; $manufacturer_kit=$row['manufacturer_kit']; $kit_id=$row['kit_id']; $kit_number=$row['kit_number']; $kit_name=$row['kit_name']; $engine_detail=$row['engine_detail']; $year_prod_kit=$row['year_prod_kit']; $scale=$row['scale']; $image_id=$row['image_id']; //-display the result of the array echo "<ul>\n"; echo "<li>" .$kit_number . " " . $manufacturer_kit . " " . $kit_name . " " . $description . " " . $year_prod_kit . " " . $engine_detail . " " . $scale . " </li>\n"; echo "<img src='".$image_id['image_id']."' width='150' height='100'/>"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } } } ?> and I stille get the same thing.... thanks sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080871 Share on other sites More sharing options...
scaleautostyle Posted July 4, 2010 Author Share Posted July 4, 2010 problem solve. sebastien Quote Link to comment https://forums.phpfreaks.com/topic/206630-why-the-picture-doesnt-appear/#findComment-1080895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.