Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8886799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:38:44+00:00 2026-06-14T21:38:44+00:00

Why the following php script doesn’t show the image. I checked that database connection

  • 0

Why the following php script doesn’t show the image. I checked that database connection is OK and Mysql Query is also Ok.

Php Code:

$upload_directory = "uploaded"; //set upload directory

$getimages = mysql_query("SELECT * FROM property_step3 WHERE propertyid =  
'$propertyid' AND active =1 AND uname = '$uname'"); 

$re2 = mysql_fetch_array($getimages)
$images = mysql_real_escape_string(htmlspecialchars(trim($re2['imgname'])));


echo '<img src="$upload_directory/$images" width="98" height="68"  /></a>'; 

May be I’m wrong..

I don’t understand why are some people are voting me DOWN ??!!

Update:

<?php
 $uname = $_SESSION['uname'];
 $check = mysql_query("SELECT * FROM property_step1 WHERE uname = '$uname' AND active 
 = 1");
 $num = mysql_num_rows($check);

if($num == 0)
{

echo "<h3>You didn't upload any property. Click <a href='publishadvert.php'>here</a> 
to publish your property</h3>";

}
else
{
    echo "<h3>You have $num published property.</h3>";

    echo "<table width='1020' cellpadding='0' cellspacing='0'>";
        echo "<tr>";
    echo "<td class='tabletr3'><b>Property Title</b></td>";
    echo "<td class='tabletr3'><b>Area</b></td>";
    echo "<td class='tabletr3'><b>State</b></td>";
        echo "<td class='tabletr3'><b>City</b></td>";
    echo "<td class='tabletr3'><b>Country</b></td>";            
    echo "<td class='tabletr3'><b>Images</b></td>";         
    echo "<td class='tabletr3'><b>Action</b></td>";         
    echo "</tr>";

    while($re = mysql_fetch_array($check))
    {
$propertyid = (int) $re['propertyid'];  
$country = mysql_real_escape_string(htmlspecialchars(trim($re['pro_country'])));
$state = mysql_real_escape_string(htmlspecialchars(trim($re['pro_state'])));
$area = mysql_real_escape_string(htmlspecialchars(trim($re['pro_area'])));
$city = mysql_real_escape_string(htmlspecialchars(trim($re['pro_city'])));
$title = mysql_real_escape_string(htmlspecialchars(trim($re['pro_title'])));

 $getimages = mysql_query("SELECT * FROM property_step3 WHERE propertyid = 
 '$propertyid' AND active =1 AND uname = '$uname'");

    $upload_directory = dirname(__file__) . '/uploaded/'; //set upload directory    
while($re2 = mysql_fetch_array($getimages))
{
$images = mysql_real_escape_string(htmlspecialchars(trim($re2['imgname'])));
}



        echo "<tr>";
            echo "<td class='tabletr2'>$title</td>";
            echo "<td class='tabletr2'>$country</td>";
            echo "<td class='tabletr2'>$state</td>";
            echo "<td class='tabletr2'>$city</td>";
            echo "<td class='tabletr2'>$area</td>";     
                  echo '<img src="'.$upload_directory.'/'.$images.'" width="98" 
 height="68"  /></a>';      

echo "<td class='tabletr2'><img src='uploaded/$images' 
/></td>";                               
echo "<td class='tabletr2'><a href='editproperty.php?propertyid=$propertyid&
uname=$uname'>Edit</a> | <a href='deleteproperty.php?propertyid=$propertyid'>Delete</a>
</td>";
    echo "</tr>";
    }  
    echo "</table>";

     }
 ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:38:46+00:00Added an answer on June 14, 2026 at 9:38 pm

    Mistake 1: What Waqar Alamgir said, but more explicitly. Trying to use variables in single quotes.

    echo '<img src="$upload_directory/$images" width="98" height="68"  /></a>'; 
    

    will output

    <img src="$upload_directory/$images" width="98" height="68"  /></a>
    

    whereas

    echo "<img src=\"$upload_directory/$images\" width=\"98\" height=\"68\"  /></a>"; 
    

    or

    echo '<img src="'. $upload_directory . '/' . $images .'" width="98" height="68"  /></a>'; 
    

    or

    echo '<img src="', $upload_directory, '/', $images, '" width="98" height="68"  /></a>'; 
    

    will output

    <img src="uploaded/theimagename.jpg" width="98" height="68"  /></a>
    

    where $images equals theimagename.jpg

    Mistake 2: (Spotted by Pankaj Khairnar)

    $re2 = mysql_fetch_array($getimages)
    

    is missing a semi-colon. This will break your script.

    $re2 = mysql_fetch_array($getimages);
    

    Mistake 3 (c/o Michael Berkowski)

    Don’t call mysql_real_escape_string() on output data

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following php script to show a random image on my
I have the following code that fetches some data from a php script. I'm
I have a PHP script that does the following: Uses file_get_contents() to get content
I have the following code validation php script: if(empty($_POST['captcha_code'])) { $error = 1; $code[3]
A php script is building the following (very complicated script that is too long
I have a php script that has the following requirement command: require_once 'HTTP/OAuth.php'; the
I was running the following PHP code: <?php </script> ?> There were no parse
i have a php script that resize image to three different resolutions on upload.
I'm learning PHP OOP and Im trying to understand why the following script doesn't
I have the following PHP script: <?php $vote_type = $_GET['type']; $book = $_GET['book']; $id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.