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 5974889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:00:21+00:00 2026-05-22T21:00:21+00:00

I am trying to get the default image if no image is uploaded by

  • 0

I am trying to get the default image if no image is uploaded by the user but I get always the image which is uploaded by the user and the default does not show up.

Here is SQL query code and CSS part.

$query="INSERT INTO tbl_images (f_naam) VALUES ('$filename')";
if($result=mysql_query($query) or die ('query fout') ){
?>
<img src="data/<?php echo $filename; ?>"  width="220" />
<?php }else{ ?>
        <img src="http://www.istockphoto.com/file_thumbview_approve/12716227/2/istockphoto_12716227-close-up-of-a-cute-young-couple-smiling-togetherjpg" width="220" />
        </div>
<?php } ?>
  • 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-05-22T21:00:22+00:00Added an answer on May 22, 2026 at 9:00 pm

    i am not sure if this is the problem BUT i suspect that even if $filename is empty, the query would run successfully and you would go into the section trying to display the uploaded image. So you might want to put a check on $filename and make sure it has something before running the query.

    I might do it something like this, untested code though.

    <?php 
    
        $picture_to_show = "http://www.istockphoto.com/file_thumbview_approve/12716227/2/istockphoto_12716227-close-up-of-a-cute-young-couple-smiling-togetherjpg";
    
        if($filename){
            $query="INSERT INTO tbl_images (f_naam) VALUES ('$filename')";
            if($result=mysql_query($query) ){
                $picture_to_show = "data/".$filename;
            }
        }   
    
    ?>
    <img src="<?php echo $picture_to_show; ?>"  width="220" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a default query to implement upon page load but
I am trying to get the node ref of file uploaded to default root
I'm trying to get an SVG image to show up on my iPhone (or
Hi I'm trying to get different versions of the default image to work for
I am trying to get a user's thumbnail from another intranet site but some
I'm trying to get the new ASP.NET Web API beta (VS 2010 default Web
So i am trying get 2 div-containers which both should contain centered text (Both
When I'm trying to change the default Image of a Control on Windows Forms
I'm trying to get just a piece of information from Facebook, but I don't
I'm trying to copy the Google image search from this page . Here is

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.