I got the image path inserted in to database by the below code but I’m not able to display it in html page…the path for the images is "images/" how do i display the actual image? i tried hard but the most i got to work was to display the file name not the image.
<?php
$mysqli = new mysqli("localhost", "root", "", "simple_login");
// TODO - Check that connection was successful.
$photo= "images/" . $_FILES["file"]["name"];
$stmt = $mysqli->prepare("INSERT INTO photo (photo) VALUES (?)");
// TODO check that $stmt creation succeeded
// "s" means the database expects a string
$stmt->bind_param("s", $photo);
$stmt->execute();
$stmt->close();
$mysqli->close(
?>
here is what I tried to display image …this only shows the file name with path…..
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("simple_login", $con);
$result = mysql_query("SELECT * FROM photo");
while($row = mysql_fetch_array($result))
{
echo $row['photo'];
echo "<br />";
}
mysql_close($con);
?>
1 Answer