From: dj at cleancode dot org Operating system: Red hat 9 PHP version: 4.3.8 PHP Bug Type: MySQL related Bug description: Data not inserting into MySQL Database
Description: ------------ When using mysql_query(), I can not insert a specific line into MySQL. However, if I have PHP echo the string I'm trying to insert into the database, and then copy and paste it into the mysql command line tool, it inserts fine. Reproduce code: --------------- $conn = mysql_connect("localhost", "organizer", "organizer") or die("Can't connecto to DB" . mysql_error()); mysql_select_db("Organizer") or die("Can't change DB: " . mysql_error()); $currdate = time(); if ($taskarr['closed'] != "") $closed_date = $currdate; else $closed_date = 0; /* insert into database. */ $q = "INSERT INTO Tasks SET post_date = $currdate, closed_date = $closed_date, last_edit = $currdate, subject = '" . $taskarr['subject'] . "', body = '" . $taskarr['body'] . "';"; echo "$q<BR><BR>"; mysql_query($q) or die("Couldn't insert data: " . mysql_error()); mysql_close(); Expected result: ---------------- The data should get inserted in the table Actual result: -------------- Doing a SELECT * FROM Tasks; shows nothing in the DB. After performing this, mysql_query() returns fine... No error from mysql_error() since mysql_query() does not return false. To make matters more interesting, if I statically set $currdate, it works. For instance: $currdate = 1090793160; The data gets inserted into the database properly. It seems if I use time() or mktime() cause the issue... -- Edit bug report at http://bugs.php.net/?id=29381&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29381&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29381&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=29381&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=29381&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=29381&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=29381&r=needscript Try newer version: http://bugs.php.net/fix.php?id=29381&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=29381&r=support Expected behavior: http://bugs.php.net/fix.php?id=29381&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=29381&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=29381&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=29381&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29381&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=29381&r=dst IIS Stability: http://bugs.php.net/fix.php?id=29381&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=29381&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=29381&r=float