torpedo91 Posted February 3, 2021 Share Posted February 3, 2021 i am in the process of creating an auction site. However the images do not show , just the placeholder. Can anyone indicate where I have gone wrong ? i am using this script to enter the items into the Database html> <head><title></title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <?php echo "<img src='auction_logo.png' id='logo'/>"; echo "<br>"; echo "<form class='add_item_form' action='check_item.php' method='POST' enctype='multipart/form-data'>"; if(isset($_GET["item"])) { if($_GET["item"]=="duplicate") { echo "<h4>Already entered this item</h4>"; echo "<br>"; echo "<h4>Please try again</h4>"; } else if($_GET["item"]=="successful") { echo "<h4>Successfully added an item!</h4>"; } } else { echo "<h4>Please add an item</h4>"; } echo "<label for='item_name' class='label'>Item Name:</label>"; echo "<input class='text' type='text' name='item_name'/>"; echo "<br>"; echo "<label for='item_description' class='label'>Item Description:</label>"; echo "<input class='text' type='text' name='item_description'>"; echo "<br>"; echo "<label for='endtime' class='label'> Ending Bid Time: </label>"; echo "<input class='text' type='text' name='endtime'>"; echo "<br>"; echo "<label for='item_pic' class='label'>Item Picture: </label>"; echo "<input class='text' type='file' value='item_pic' name='item_pic'>"; echo "<br>"; echo "<input class='submit' type='submit' value='Add Item'/>"; echo "</form>"; ?> </body> </html> This script displays the items : <html> <head><title></title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <?php session_start(); if(!isset($_SESSION["username"])) { header("Location:login.php"); } else { $DBHOST = "localhost"; $DBUSER = "root"; $DBPWD = ""; $DBNAME = "customs_auction"; $conn = new mysqli($DBHOST, $DBUSER, $DBPWD, $DBNAME); if($conn->connect_error) { die("Connection failed!".$conn->connect_error); } echo "<img src='auction_logo.png' id='logo'/>"; echo "<a href='logout.php' class='logout button'>Logout </a>"; $statement = "SELECT * FROM item"; $result = $conn->query($statement); while($row = $result->fetch_assoc()) { $iid = $row["item_id"]; $iname= $row["item_name"]; $ipic = $row["item_pic"]; $icurrentp = $row["current_bid"]; $iimg = "item/"; $iimg = $iimg.$row["item_pic"]; $link = "item_details.php?item_id="; $item_details = $link.$iid; echo "<div class='item'>"; echo "<div class='item_row'>Item Id: $iid</div>"; echo "<div class='item_row'>Item Name: $iname</div>"; echo "<img class='item_img' src='$iimg' alt='image'>"; echo "<div class='item_row'>Current Bid: $$icurrentp</div>"; echo "<div class='item_row' ><a class='link' href='$item_details'>Item Details</a></div>"; echo "</div>"; }/*display all the items on screen*/ $conn->close(); }/*prevent direct access by user*/ ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/312094-photo-not-dislpaying/ Share on other sites More sharing options...
gw1500se Posted February 3, 2021 Share Posted February 3, 2021 Did you look at the resulting HTML source to see if it looks like you expect? Quote Link to comment https://forums.phpfreaks.com/topic/312094-photo-not-dislpaying/#findComment-1584221 Share on other sites More sharing options...
Barand Posted February 3, 2021 Share Posted February 3, 2021 https://www.php.net/manual/en/features.file-upload.php Quote Link to comment https://forums.phpfreaks.com/topic/312094-photo-not-dislpaying/#findComment-1584222 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.