• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 569
  • Last Modified:

php queston

I'm saving some text areas to a database and if they are empty I'm ending up with '0' in the field in the DB.

the default value is null for the field (mysql).  How can I format the variable before sending it to the database to not show zero.. can I insert a null value?  

My alternative is to live with the zeros and handle them either in the view php (mvc) or in a jquery script to replace with and empty string.  Seems kind of cheesy to do it that way though.

How can I do this properly in php before I send it to the db?

(FYI it's php within CodeIgniter)
0
tf2012
Asked:
tf2012
4 Solutions
 
haloexpertsexchangeCommented:
you need to add php as a topic for this question to get the experts from that area instead of javascript.
You should be able to piece together a query that says in case of an empty string '' insert NULL instead.
<Link to non-authoritative competing site deleted as per EE guidelines by COBOLdinosaur, Topic Advisor>
0
 
COBOLdinosaurCommented:
A default null is binary 0 that presents as 0.

For a text field the normal default is empty; so why do you need a default idf you don't really have a value, and default null gives you a problem.

Cd&
0
 
Marco GasiFreelancerCommented:
tf2012, can you post here the CREATE query of your table? It seems there is something wrong in the table definition and seeing this cold help us to identify the problem.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Chris StanyonCommented:
We also need to see the codeigniter code for the controller and the model
0
 
tf2012Author Commented:
I'll post the codeigniter code bits here tomorrow when I'm back on the project thanks for waiting!
0
 
tf2012Author Commented:
I got it sorted out, thank your  for waiting
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now