|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-07-26 06:52 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 10:00:01 2025 UTC |
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...