nethken nethken - 2 years ago 118
HTML Question

Image not showing on image slider

Hello im creating a dynamic image slider but the image is not showing. I can upload image in the file directory. I don't know what is the problem if the database is the problem or what. I'm new to html and css also to php. Can someone give me ideas what is the caused of not showing the images?

here it is the image is not showing but i can upload file to my gallery file directory.
enter image description here

here is my database sql.
enter image description here

here is my php code.

//for connecting db
if (!isset($_FILES['image']['tmp_name'])) {
echo "";
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name= addslashes($_FILES['image']['name']);
move_uploaded_file($_FILES["image"]["tmp_name"],"gallery/" . $_FILES["image"]["name"]);
$photo="gallery/" . $_FILES["image"]["name"];

$query = mysqli_query($mysqli, "INSERT INTO images(photo)VALUES('$photo')");
$result = $query;

echo '<script type="text/javascript">alert("image successfully uploaded ");window.location=\'index.php\';</script>';
<!DOCTYPE html>
<link href="css/style.css" rel="stylesheet" />
<script src=""></script>
<script src="js/slider.js"></script>
$(document).ready(function () {
animation: 'fade',
controlsContainer: '.flexslider'
<div class="container">
<form class="form" action="" method="POST" enctype="multipart/form-data">
<div class="image">
<p>Upload images and try your self </p>
<div class="col-sm-4">
<input class="form-control" id="image" name="image" type="file" onchange='AlertFilesize();'/>
<input type="submit" value="image"/>
<div class="flexslider">
<ul class="slides">
// Creating query to fetch images from database.
$query = mysqli_query($mysqli, "SELECT * from images order by id desc limit 5");
$result = $query;
while($r = mysqli_fetch_array($result)){
<img src="<?php echo $r['photo'];?>" width="400px" height="300px"/>

here is my connect.php

// hostname or ip of server
// username and password to log onto db server
// name of database

////////////// Do not edit below/////////
$mysqli = new mysqli($servername,$dbusername,$dbpassword,$dbname);
printf("Connect failed: %s\n", $mysql->connect_error);


Apb Apb
Answer Source

Image shows your column name is image and you are fetching records by column name photo.

Just change

<img src="<?php echo $r['photo'];?>" width="400px" height="300px"/>


<img src="<?php echo $r['image'];?>" width="400px" height="300px"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download