Error in Displaying Image using Php and mysql through folder and mysql url -


im storing image in folder using php , saving name url in mysql , need display folder using saved url in mysql database., tried following facing error in display.. images saving on folder while upload. displaying getting broken images..

insert.php

<form action="imagebackend.php" method="post" enctype="multipart/form- data"> <table border="0" cellspacing="0" align="center" cellpadding="3"    bordercolor="#cccccc"> <tr> <td>file:</td> <td><input type="file" name="filep" size=45></td> </tr> <tr> <td colspan=2><p align="center"> <input type="submit" name="action" value="load"> </td> </tr> </table> </form>  <?php if ($_post["action"] == "load") { $folder = "c:/wamp/www/userlogin/pic/"; move_uploaded_file($_files["filep"]["tmp_name"]    ,"$folder".$_files["filep"]["name"]); echo "<p align=center>file ".$_files["filep"]["name"]."loaded..."; $result = mysqli_connect("localhost", "root", "") or die ("could not     save image name error: " . mysql_error()); mysqli_select_db($result, "login") or die("could not select database"); mysqli_query($result, "insert picture (ul)    values('".$_files['filep']['name']."')"); if($result) { echo "image name saved database"; } else { //gives , error if not echo "sorry, there problem uploading file."; } } ?> 

and display.php

<?php //retrieves data mysql $conn= mysqli_connect("localhost", "root", "") or die ("could not save  image name error: " . mysql_error()); mysqli_select_db($conn, "login") or die("could not select database"); $data = mysqli_query($conn, "select ul picture") or die(mysqli_error()); //puts array $file_path = "c:/wamp/www/userlogin/pic/"; while($row = mysqli_fetch_assoc($data))  {//outputs image , other data $src=$file_path.$row['ul']; echo '<img src=".$src."><br>'; echo"no images found"; } ?> 

kindly me on ., im getting broken image tried lot im wasting time 3 days on this.

update code...

insert.php

<form action="" method="post" enctype="multipart/form-data"> <table border="0" cellspacing="0" align="center" cellpadding="3" bordercolor="#cccccc">    <tr>        <td>file:</td>        <td><input type="file" name="filep" size=45></td>    </tr>    <tr>        <td colspan=2><p align="center"><input type="submit" name="action" value="load"></td>    </tr> </table> </form>  <?php if ($_server["request_method"] == "post"){    $folder = "userlogin/pic/";    move_uploaded_file($_files["filep"]["tmp_name"], $folder . $_files["filep"]["name"]);    echo "<p align=center>file ".$_files["filep"]["name"]."loaded...";    $result = mysqli_connect("localhost", "root", "") or die ("could not save image name error: " . mysql_error());    mysqli_select_db($result, "login") or die("could not select database");    $filename = $_files['filep']['name'];    mysqli_query($result, "insert picture(ul)values('$filename')");    if($result) {         echo " image name saved database";    }else {        //gives , error if not        echo "sorry, there problem uploading file.";    } } ?> 

display.php

<?php //retrieves data mysql $conn = mysqli_connect("localhost", "root", "") or die ("could not save image name error: " . mysql_error()); mysqli_select_db($conn, "login") or die("could not select database"); $data = mysqli_query($conn, "select ul picture") or die(mysqli_error()); //puts array $file_path = "userlogin/pic/"; if(mysqli_num_rows($data) > 0){     while($row = mysqli_fetch_array($data)) {         //outputs image , other data         $src= $file_path . $row['ul']; ?>         <img src="<?php echo $src; ?>"><br/>     <?php } }else{     echo"no images found"; } ?> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -