i need to have null date from php and send to mysql
how to make a null date so that i could insert it the database
it should be in the format '00-00-0000';
suggested using a literal placeholder, but that approach needs clarification. There are two different ways to represent "no date" in MySQL: use the SQL NULL value (recommended) or use the server's zero-date placeholder. They behave differently, and the zero-date string must match MySQL's format and server mode settings.
Prefer SQL NULL for missing dates. Make the column nullable, then insert an actual NULL (not the string "NULL"). With prepared statements you can pass a PHP null value or bind it as a NULL parameter; this avoids string-format and SQL injection issues. See the PDO bind example in the PHP manual for safe binding (PDO::bindValue).
If you need a zero-date placeholder instead, MySQL uses 0000-00-00 (and 0000-00-00 00:00:00 for DATETIME). Be cautious: strict SQL modes (for example NO_ZERO_DATE or strict mode) may reject zero dates or convert invalid values to errors. Consult MySQL docs on date types and sql_mode before relying on zero dates (Date and Time Types, SQL Modes).
Practical tips: ensure the column is DATE/DATETIME and allows NULL (you can alter it to DATE NULL), validate and format input with PHP's DateTime class before sending it, and use prepared statements (PDO or mysqli) rather than building queries by string concatenation. This keeps the intent clear on the database side and avoids surprises from server SQL modes.
just put '00-00-0000' in a variable then use this variable as you insert it in a database.
$var='00-00-0000';
$query="Insert into table1 values ('$etc','$var')";
$result=mysql_query($query); We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.