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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:18:22+00:00 2026-06-12T10:18:22+00:00

My database have a profile table with image column. I want to set the

  • 0

My database have a profile table with image column. I want to set the default image using default value if the user are not inserting his image URL in the web form.

The column definition:

profile_image varchar(255) NOT NULL DEFAULT 'http://i.imgur.com/U.png'

I already inserted the default image URL in phpmyadmin but everytime I click submit at web form, every key in data at webform is stored in the profile table but the image column is empty.

I know I can do this with form by adding the image URL in web form but I want to do this via mysql.

This problem is solved because I insert the image at php insert but how do I use the null value to let mysql know I’m sending NULL? Is this the correct way of using Null?

$nl = NULL; 
$query = "INSERT INTO `student` (
`name` ,
`emel` ,
`address` ,
`profile_image` 
)
VALUES (
'$name', '$emel', '$add', '$nl');";

The above code won’t work. The profile_image column is still empty.

  • 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-12T10:18:22+00:00Added an answer on June 12, 2026 at 10:18 am

    You need to do 2 things:

    1.) specify a default value of the column for the image, maybe something like default.jpg
    (I believe you’ve already done this)

    2.) ensure your php script provides a null value (not empty) or don't specify the value at all during insertion/modification, so your mysql knows it needs to use the default value. Or you can handle the logic in your php script to provide the url for the default image. I’d avoid some complicated functions in SQL, because your logic may change over time and SQL server really shouldn’t be responsible for handling application logic.

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

Sidebar

Related Questions

My database table have a Timestamp column named as inTime and i am using
I have a table called profile in mysql database Table structure: user | hasimg
hi i am using GORM and i have an user table in database. also
I have database application, I want to allow the user to restore the deleted
I have a database situation where I'd like to get a user profile row
I already have a model named profile and corresponding database table profiles. Now i
I have a ingredient mysql database. I let the user save to their profile
I'm using sessions to receive my info from my database table... But I'm not
i have database with two values id and val so i want to ask
i have database table like this +-------+--------------+----------+ | id | ip | date |

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.