Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

MySQL Default Values

New Here ,
Nov 30, 2007 Nov 30, 2007

Copy link to clipboard

Copied

I have created a site for a local artist at http://www.everythingheidi.com/iloveyoucards.org/postExperience.php

When a user upload a message without a photo the mySQL database table get a new row with 4 simple pieces of data, the name, the message and the location of the image. This all works great except for some reason, the image_url field in my database is not updated with the default value in the case where the user uploads a message with no photo. This field is configured to be not null and a default value is set according to the view of the table in phpMyAdmin. If I use the command line to run the following sql the default value is updated.

insert into posts(name, post)
values('test name', 'test post');

I am a little bit at a loss as to how the app is able to get a null value into this field which is set to not null and has a default value declared.

Any help is greatly appreciated.

thanks,
- Tanner
TOPICS
Server side applications

Views

271
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2007 Nov 30, 2007

Copy link to clipboard

Copied

LATEST
On Fri, 30 Nov 2007 20:21:13 +0000 (UTC), "mediaMan6476"
<webforumsuser@macromedia.com> wrote:

>If I
>use the command line to run the following sql the default value is updated.
>
> insert into posts(name, post)
> values('test name', 'test post');

That suggests that you are inserting zero length strings, which is not
the same thing as a null value. Your code that does the insert needs to
validate the image_url and not include it in the insert if nothing was
provided.

Gary

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines