mysql - am getting something like this,"Failed to load resource: the server responded with a status of 404 (Not Found)" -


i getting details of product database. here sample code unable display images of products! can me out please?

the code insert product details in database:

<!doctype> <?php include("includes/db.php"); ?> <html> <head> <title> inserting product</title>  <script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script>   <script>   tinymce.init({ selector:'textarea' });   </script>  </head> <body bgcolor="skyblue"> <form action="insert_product.php" method="post" enctype="multipart/form-data">    <table align="center" width="700" border="2" bgcolor="orange">      <tr align="center">           <td colspan="7"><h2>insert new post here.</h2></td>      </tr>      <tr>           <td align="right"><b>product title:</b></td>           <td><input type="text" name="product_title" size="50" required /></td>      </tr>      <tr>           <td align="right"><b>product category:</b></td>           <td>           <select name="product_cat" required>           <option>select categogory</option>             <?php              $get_cats = "select * categories";     $run_cats = mysqli_query($con, $get_cats);      while($row_cats=mysqli_fetch_array($run_cats)){          $cat_id = $row_cats['cat_id'];         $cat_title = $row_cats['cat_title'];         echo "<option value='$cat_id'>$cat_title</option>";     }             ?>           </select>           </td>      </tr>      <tr>           <td align="right"><b>product brand:</b></td>           <td>           <select name="product_brand" required>           <option>select brand</option>             <?php              $get_brands = "select * brands";     $run_brands = mysqli_query($con, $get_brands);      while($row_brands=mysqli_fetch_array($run_brands)){          $brand_id = $row_brands['brand_id'];         $brand_title = $row_brands['brand_title'];         echo "<option value='$brand_id'>$brand_title</option>";     }             ?>           </select>           </td>      </tr>      <tr>           <td align="right"><b>product image:</b></td>           <td><input type="file" name="product_image" required/></td>      </tr>      <tr>           <td align="right"><b>product price:</b></td>           <td><input type="text" name="product_price" size="50" required/></td>      </tr>      <tr>           <td align="right"><b>product description:</b></td>           <td><textarea name="product_desc" cols="20" rows="10"></textarea></td>      </tr>      <tr>           <td align="right"><b>product keywords</b></td>           <td><input type="text" name="product_keywords" size="50" required/></td>      </tr>      <tr align="center">           <td colspan="7"><b><input type="submit" name="insert_post" value="insert product now"/></b></td>      </tr>    </table> </form> </body> </html> <?php    if(isset($_post['insert_post'])){        //getting text data fields.      $product_title = $_post ['product_title'];       $product_cat = $_post ['product_cat'];       $product_brand = $_post ['product_brand'];       $product_price = $_post ['product_price'];       $product_desc = $_post ['product_desc'];       $product_keywords = $_post ['product_keywords'];        //getting image data fields.       $product_image = $_files['product_image'][name];       $product_image_tmp = $_files['product_image']['tmp_name'];        move_uploaded_file($product_image_tmp,"product_images/$product_image");        $insert_product = "insert products (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values ('$product_cat','$product_brand','$product_title','$product_price','$product_desc',' $product_image','$product_keywords')";    $insert_pro = mysqli_query($con,$insert_product);    if($insert_pro) {        echo "<script>alert('product has been inserted!')</script>";        echo "<script>window.open('insert_product.php','_self')</script>";    }    } ?> 

the function part.

    <?php $con = mysqli_connect("localhost","root","","ecommerce"); //getting categories function getcats(){     global $con;     $get_cats = "select * categories";     $run_cats = mysqli_query($con, $get_cats);      while($row_cats=mysqli_fetch_array($run_cats)){          $cat_id = $row_cats['cat_id'];         $cat_title = $row_cats['cat_title'];         echo "<li><a href='#'>$cat_title</a></li>";     }      }  //getting brands function getbrands(){     global $con;     $get_brands = "select * brands";     $run_brands = mysqli_query($con, $get_brands);      while($row_brands=mysqli_fetch_array($run_brands)){          $brand_id = $row_brands['brand_id'];         $brand_title = $row_brands['brand_title'];         echo "<li><a href='#'>$brand_title</a></li>";     }      }      function getpro() {         global $con;          $get_pro = "select * products order rand() limit 1,6";         $run_pro = mysqli_query($con, $get_pro);         while($row_pro=mysqli_fetch_array($run_pro)){             $pro_id = $row_pro['product_id'];             $pro_cat = $row_pro['product_cat'];             $pro_brand = $row_pro['product_brand'];             $pro_title = $row_pro['product_title'];             $pro_price = $row_pro['product_price'];             $pro_image = $row_pro['product_image'];             echo "             <div id='single_product'>             <h3>$pro_title</h3>             <img src='\\ecommerce\admin_area\product_images\$pro_image' width='180' height='180' />              <p><b> $pro_price </b></p>             </div>             ";         }         }                                ?>     **the web page display details**     <!doctype> <?php include("functions/functions.php"); ?> <html>      <head>         <title>gal baking services ltd online shop.</title>      <link rel="stylesheet" href="admin_area/product_images/style.css" media="all" />       </head> <body>     <div class="main_wrapper">          <div class="header_wrapper">          <img id="logo" src="images/ad bunner.jpg" />         <img id="bunner" src="images/ad bunner.jpg" />         </div>         <div class="menubar">             <ul id="menu">                  <li><a href="#">home</a></li>                  <li><a href="#">all products</a></li>                  <li><a href="#">my account</a></li>                  <li><a href="#">sign up</a></li>                  <li><a href="#">shopping cart</a></li>                  <li><a href="#">contact us</a></li>             </ul>             <div id="form">                  <form method="get" action="result.php" enctype="multipart/form-data">                     <input type="text" name="user_query" placeholder="search product" />                     <input type="submit" name="search" value="search" />                  </form>             </div>         </div>         <div class="content_wrapper">         <div id="sidebar">              <div id="sidebar_title">categories</div>            <ul id="carts">            <?php getcats();?>             </ul>          <div id="sidebar_title">brands</div>             <ul id="carts">            <?php getbrands();?>            </ul>          </div>         </div>         <div id="content_area">            <div id="products_box">             <?php getpro(); ?>             </div>         </div>         </div>         <div id="footer">             <h2 style="text-align:center; padding-top:30px;">&copy;2016 www.krumblefresh.com </h2>         </div>     </div> </body> </html> 

i wish thank participation , support . after straggling code on how display images mysql database,i came realize code perfect had made silly mistakes on following lines of insert_product.php file, "$product_image = $_files['product_image'][name];".i failed enclose 'name' inside single quotes ''.it should be, $product_image = $_files['product_image']['name'];. also,on following line *

$insert_product = "insert products (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values ('$product_cat','$product_brand', '$product_title','$product_price','$product_desc', ' $product_image','$product_keywords')";

*, had included blank space inside single quotes near $product_image.its supposed ,

$insert_product = "insert products (product_cat,product_brand,product_title,product_price,product_desc,product_image,product_keywords) values ('$product_cat','$product_brand','$product_title','$product_price','$product_desc','$product_image','$product_keywords')"; thank all.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -