-1

I'm trying to display images in my project. I've stored the images in the local directory (i.e. the sub-folder in which I'm working on using xampp) and in database (php My Admin) stored the path of the image.

Now the problem is that I'm facing a warning saying

Use of undefined constant Image_1 - assumed 'Image_1' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\php\web-pages\detail page\detailEx.php on line 32

I wasn't actually able to display the image at all with this,

echo "<img src='$row[Image_1]' height:400px width=400px/>";

So I tried to changed it with this

echo "<img src='".$row[Image_1]."' height:400px width=400px/>";

And that's where I got this warning.

Here's my whole code

<div style="width:100%; height:80%; margin-top:4%;">
    <div style="width:50%; height:100%; float:left;">           
        <div style="width:100%; height:83%; background-color: aliceblue;">
            <center style="padding-top: 40px">                
                <?php
                    $con = mysqli_connect("localhost", "root", "", "automobile");
                    $result = mysqli_query($con,"select * from vehicle");        

                    while($row = mysqli_fetch_array($result))
                    {
                        if($_GET['vid'] == $row['vehicle_id']) {
                            echo "<img src='".$row[Image_1]."' height:400px width=400px/>";
                        }
                    }
                ?>
            </center>
        </div>

This is what I get when I try to display the image

Can anyone please help me??

P.S. I'm just a beginner at php and also I know that this question is a duplicate but the already asked ones didn't actually solved my problem, so here I am!

Rushit
  • 11
  • 1
  • 2

1 Answers1

3

Change from

echo "<img src='".$row[Image_1]."' height:400px width=400px/>";

to

echo "<img src='".$row['Image_1']."' height:400px width=400px/>";