You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ””)’ at line 2

There is a single quote in $submitsubject or $submit_message Why is this a problem? The single quote char terminates the string in MySQL and everything past that is treated as a sql command. You REALLY don’t want to write your sql like that. At best, your application will break intermittently (as you’re observing) and at worst, you have just introduced … Read more

SQL – IF EXISTS UPDATE ELSE INSERT INTO

What I’m trying to do is INSERT subscribers in my database, but IF EXISTS it should UPDATE the row, ELSE INSERT INTO a new row. Ofcourse I connect to the database first and GET the $name, $email and $birthday from the url string. This works, but just adds the new row; Here’s what I tried; … Read more

Get the new record primary key ID from MySQL insert query?

You need to use the LAST_INSERT_ID() function: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_last-insert-id Eg: This will get you back the PRIMARY KEY value of the last row that you inserted: The ID that was generated is maintained in the server on a per-connection basis. This means that the value returned by the function to a given client is the first … Read more

Object of class DateTime could not be converted to string

Because $newDate is an object of type DateTime, not a string. The documentation is explicit: Returns new DateTime object formatted according to the specified format. If you want to convert from a string to DateTime back to string to change the format, call DateTime::format at the end to get a formatted string out of your DateTime. ShareFollowa