0

I am creating a shopping cart in mySQLi and PHP. I inserted the products with images into PhpMyAdmin (I typed - zdjecia/photo.png in the zdjecie_produktu) This is my code for this part in PHP. I am only starting PHP and I've been following this tutorial https://www.youtube.com/watch?v=ka2ea2LL36g. Everything seems to work fine, just these pictures don't show up :(

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>x</title>
    <link rel="stylesheet" href="style.css">
    <link rel="preconnect" href="https://fonts.gstatic.com"> 
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="shortcut icon" href="favico.png" />

</head>


<body>
    
    <section class="home">
    <div class="slider">

        <div class="slide active" id="slide" style="background-image: url(tlo1.jpg)" ><div class="header">

    <div class="container">
    <div class="navbar">
        <div class="darmowadostawa">
    <p>100% WYRÓB DOMOWY | Gwarancja komfortu</p>
</div>
<div class="emailugory">
    <a href="mailto:#">E-mail:xxx</a>
    <a href="tel:#">Numer telefonu:xxx-xxx-xxx</a>
</div>
        
        <nav class="indeksik">

            <ul id="MenuItems">
<li class="logo"><a href="index.html"><img src="logooficjalne.png" class="carolinepng"></a></li>
        <li><a href="onas.html">O nas</a></li>
            <li><a href="swieceswiateczne.html">Świece świąteczne</a></li>
                <li><a href="naturalneswiecezpachowe.html">Naturalne świece zapachowe</a></li>      
                <li><a href="szklo.html">Świece zapachowe w szkle</a></li>  
                <li><a href="#.html">Zapachy</a>

                <ul>
                    <li><a href="owocowe.html">Owocowe</a></li>
                    <li><a href="słodkie.html">Słodkie</a></li>
                    <li><a href="eleganckie.html">Eleganckie</a></li>
                    <li><a href="kwiatowe.html">Kwiatowe</a></li>
                    <li><a href="świąteczne.html">Świąteczne</a></li>
                </ul>
            </li>
            <li><a href="blog.html">Blog</a></li>



 <li class="cart"> <a href="cart.html"> <i class="fab fa-opencart"><img src="cart.png" width="20px" margin-top="0px;"></i><span class="cart-span">0</span> </a> </li>
            </ul>
            </nav>
            

    


    
        <img src="menu.png" class="menu-icon" onclick="menutoggle()">
    </div>
    <div class="caption">
            <h1 class="nowysklep">NOWY SKLEP</h1>
            <p>Świece Caroline Homemade Candles to nowa marka domowych świec zapachowych. Nasze świece produkowane są ręcznie w zaciszu domowym z naturalnego wosku sojowego.</p>
            <a href="produkty.html">Kup teraz</a>
        </div>


    </div>
</div>
</div>

        <div class="slide" id="slide" style="background-image: url(tlo2.jpg)"><div class="header">

    <div class="container">
    <div class="navbar">
        <div class="darmowadostawa">
    <p>100% WYRÓB DOMOWY | Gwarancja komfortu</p>
</div>
<div class="emailugory">
    <a href="mailto:#">E-mail:xxx</a>
    <a href="tel:#">Numer telefonu:xxx-xxx-xxx</a>
</div>
        <nav>

            <ul id="MenuItems">
<li class="logo"><a href="index.html"><img src="logooficjalne.png" class="carolinepng"></a></li>        
<li><a href="onas.html">O nas</a></li>
            <li><a href="swieceswiateczne.html">Świece świąteczne</a></li>
                <li><a href="naturalneswiecezapachowe.html">Naturalne świece zapachowe</a></li>     
                <li><a href="szklo.html">Świece zapachowe w szkle</a></li>  
                <li><a href="#.html">Zapachy</a>

                <ul>
                    <li><a href="owocowe.html">Owocowe</a></li>
                    <li><a href="słodkie.html">Słodkie</a></li>
                    <li><a href="eleganckie.html">Eleganckie</a></li>
                    <li><a href="kwiatowe.html">Kwiatowe</a></li>
                    <li><a href="świąteczne.html">Świąteczne</a></li>
                </ul>
            </li>
            <li><a href="blog.html">Blog</a></li>



 <li class="cart"> <a href="cart.html"> <i class="fab fa-opencart"><img src="cart.png" width="20px" margin-top="0px;"></i><span class="cart-span">0</span> </a> </li>
            </ul>
            </nav>
            

    


    
        <img src="menu.png" class="menu-icon" onclick="menutoggle()">
    </div>
    <div class="caption">
            <h1 class="darmowa">DARMOWA DOSTAWA OD 100ZŁ</h1>
            <p>Darmowa dostawa już od 100zł.<br> Dostępny Kurier/Paczkomaty Inpost.</p>
        </div>


    </div>
</div>
</div>


        <div class="slide" id="slide" style="background-image: url(tlo3.jpg)" ><div class="header">

    <div class="container">
    <div class="navbar">
        <div class="darmowadostawa">
    <p>100% WYRÓB DOMOWY | Gwarancja komfortu</p>
</div>
<div class="emailugory">
    <a href="mailto:#">E-mail:xxx</a>
    <a href="tel:#">Numer telefonu:xxx-xxx-xxx</a>
</div>
        <nav>

            <ul id="MenuItems">
<li class="logo"><a href="index.html"><img src="logooficjalne.png" class="carolinepng"></a></li>    
<li><a href="onas.html">O nas</a></li>  
            <li><a href="swieceswiateczne.html">Świece świąteczne</a></li>
                <li><a href="naturalneswiecezapachowe.html">Naturalne świece zapachowe</a></li>     
                <li><a href="szklo.html">Świece zapachowe w szkle</a></li>  
                <li><a href="#.html">Zapachy</a>

                <ul>
                    <li><a href="owocowe.html">Owocowe</a></li>
                    <li><a href="słodkie.html">Słodkie</a></li>
                    <li><a href="eleganckie.html">Eleganckie</a></li>
                    <li><a href="kwiatowe.html">Kwiatowe</a></li>
                    <li><a href="świąteczne.html">Świąteczne</a></li>
                </ul>
            </li>
            <li><a href="blog.html">Blog</a></li>



 <li class="cart"> <a href="cart.html"> <i class="fab fa-opencart"><img src="cart.png" width="20px" margin-top="0px;"></i><span class="cart-span">0</span> </a> </li>
            </ul>
            </nav>
            

    


    
        <img src="menu.png" class="menu-icon" onclick="menutoggle()">
    </div>
    <div class="caption">
            <h1 class="przyjemnosc">ŚWIAT PRZYJEMNOŚĆI</h1>
            <p>Świece Caroline Homemade Candles są naturalne jak i również ekologiczne. Swój produkt tworzymy z pasją i zamiłowaniem. Zapraszamy Cię do naszego świata przyjemności</p>
            <a href="produkty.html">Kup teraz</a>
        </div>


    </div>
</div>
</div>
</div>
    <div class="controls">
        <div class="prev"><</div>
        <div class="next">></div>

    </div>
<div class="indicator">
</div>
</section>

<!-----featured categories ------->
 
 <div class="categories">
    <div class="small-container">
    <div class="row">
        <div class="col-3">
            <img src="categories-1.png">
        </div>
        <div class="col-3">
            <img src="categories-2.png">
        </div>
        <div class="col-3">
            <img src="categories-3.png">
        </div>
        </div>
        

    </div>
 </div>
 <!----- featured products----->
 <div class="container">
    <div class="row">
        <?php
        include 'config.php';
        $stmt = $conn->prepare("SELECT * FROM product");
        $stmt->execute();
        $result = $stmt->get_result();
        while($row = $result->fetch_assoc());
        ?>
        <div class="col-lg-3">
                <div class="card-deck">
                    <div class="card p-2 border-secondary mb-2">
                        <img src="<?= $row['zdjecie_produktu'] ?>" class="card-img-top" height="250">
                    </div>
                </div>          
 </div>
<?php T_ENDWHILE ?>

 </div>
</div>
    
 <!----- footer ----->
 
        <footer>
            <div class="column">
            <ul class="footer-links-main">
                <li><a href="onas.html">O nas</a></li>
                <li><a href="produkty.html">Produkty</a></li>
                <li><a href="polityka.html">Regulamin</a></li>
                <li><a href="contact.html">Kontakt</a></li>
                <li><a href="faq.html">FAQ</a></li>
            </ul>
        </div>
            <div class="footer-sm"> 
                <div class="column2">
                <h3 class="kontakth3">Kontakt</h3>
                <p class="kontaktp">Adres e-mail:xxx</p>
                <p class="kontaktp">Numer telefonu:xxx</p>
                        </div>
        </div>
        </footer>
    <!---- js for toggle menu--->
    <script>
        var MenuItems = document.getElementById("MenuItems");

        MenuItems.style.maxHeight = "0px";

        function menutoggle(){
            if (MenuItems.style.maxHeight == "0px")
            {
                MenuItems.style.maxHeight = "200px";
            }
            else
            {
                MenuItems.style.maxHeight = "0px";
            }
        }
    </script>
    <script src="main.js"></script>
    <script src="https://unpkg.com/ionicons@5.2.3/dist/ionicons.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
 </body> 

</html>

The code has no errors and a default broken image icon shows up instead of pictures.

and this is my config.php

<?php
$conn = new mysqli("localhost","root","","cart_system");
if($conn->connect_error){
    die("Connection Failed".$conn->connect_error);
}
?>
  • 1
    _Side note:_ PHPMyAdmin is just a web based admin gui written in PHP for managing MySQL databases. Your application talks to MySQL server directly and has nothing to do with PHPMyAdmin. – M. Eriksson Nov 28 '20 at 14:03
  • _"and little icon shows up instead of pictures"_ - ?? You really need to give us way more context here. What icon? What does the generated HTML code look like? Is the image url correct? Can you access the image directly through your browser on the image url? How did you upload them? Are you sure the upload worked? Are you sure the database contains the correct path? You haven't given us anything to go on here. – M. Eriksson Nov 28 '20 at 14:05
  • You need to stop manually checking for errors. Please read: [Should we ever check for mysqli_connect() errors manually?](https://stackoverflow.com/q/58808332/1839439) and [Should I manually check for errors when calling “mysqli_stmt_prepare”?](https://stackoverflow.com/q/62216426/1839439) – Dharman Nov 28 '20 at 14:10
  • If you are only starting to learn PHP then you should learn PDO instead of mysqli. PDO is much easier and more suitable for beginners. Start here https://phpdelusions.net/pdo – Dharman Nov 28 '20 at 14:10
  • @Magnus Eriksson 1. an icon of little default picture? idk how to describe that... these icons show up when the url of an image is wrong, but mine is for sure correct. i checked 3 times. 2. i will paste my whole HTML code into the question. 3. yes. 4. what do u mean? 5. i created a new folder for these pictures, created a table in mySQLi and in a cell made for pictures I typed _folder_/_photo_.png... 6. i think so, i uploaded them twice. – mvarxzia ASMR Nov 28 '20 at 14:13
  • _"an icon of little default picture"_ - So it's the browsers default broken image icon? That clears that up. Either way, please [edit the question](https://stackoverflow.com/posts/65050375/edit) to include all needed information, or other users might miss the information when it's only posted in comments. – M. Eriksson Nov 28 '20 at 14:19
  • Yes. it's the browsers' broken image icon. Okay I will add the info into the question – mvarxzia ASMR Nov 28 '20 at 14:20
  • @MagnusEriksson Its says – mvarxzia ASMR Nov 28 '20 at 15:05

0 Answers0