Solved

MySQL Default Value

Posted on 2011-03-21
2
351 Views
Last Modified: 2012-05-11
When I try to enter a default value for a TEXT column in my MySQL database it will not let me. Is it possible to have a default value in a MySQL TEXT field?

I'm trying to write some PHP code that enters data in the MySQL databse & not being able to set a default field in the MySQL TEXT field is causeing some issues....

FYI...I am using PhP MyAdmin to try to set it up
0
Comment
Question by:wantabe2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35179867
From the reference:
http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html
BLOB and TEXT columns cannot be assigned a default value.

so, you might try VARCHAR data type instead, if it's ok for that:
http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html

or, remove the NULL constraint, so that the field does allow NULLS.

note: a TEXT means very large text, which shall normally allow null ...
0
 
LVL 2

Expert Comment

by:ramkihardy
ID: 35179889
simple....
before passing values to the databse...
Check the textfiled is null....
if its is null..then pass the default value
else
pass the textfield value to the database...
Regards
Ramki
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question