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'm trying to get an SVG image to show up on my iPhone (or
Question I am trying to dynamically get the default for a type that is
Trying to get an ASP application deployed; it worked for a while but then
When I'm trying to change the default Image of a Control on Windows Forms
Trying to get the findcontrol to work so I can set the default value
I'm trying to get some custom views for a content query rollup working in
I'm trying to get a fake movie website going for a University project. But
I am trying to get the following script to replace the default images by
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get my css / C# functions to look like this: body {

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.