I am facing a weird problem. I'm using a piece of code that's workin 100% throughout my website, but in a particular place does not work. Here's the code :
$stmt_insert_query = "INSERT INTO mya_events(event_id, artist_id, event_title, date, event_text, event_start, event_duration, genre, soundcloud_preview, event_type, country, ext, clicks, active) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt_insert = $db->prepare($stmt_insert_query);
$stmt_insert->bindValue(1, $next_avail, PDO::PARAM_INT);
$stmt_insert->bindValue(2, $_id, PDO::PARAM_INT);
$stmt_insert->bindValue(3, $_POST['event_title'], PDO::PARAM_STR);
$stmt_insert->bindValue(4, $event_date, PDO::PARAM_STR);
$stmt_insert->bindValue(5, $_POST['event_text'], PDO::PARAM_STR);
$stmt_insert->bindValue(6, $_POST['event_start'], PDO::PARAM_STR);
$stmt_insert->bindValue(7, $_POST['event_duration'], PDO::PARAM_STR);
$stmt_insert->bindValue(8, 'electronica', PDO::PARAM_STR);
$stmt_insert->bindValue(9, '', PDO::PARAM_STR);
$stmt_insert->bindValue(10, 'dj_event', PDO::PARAM_STR);
$stmt_insert->bindValue(11, 'US', PDO::PARAM_STR);
$stmt_insert->bindValue(12, '', PDO::PARAM_STR);
$stmt_insert->bindValue(13, 0, PDO::PARAM_INT);
$stmt_insert->bindValue(14, 'y', PDO::PARAM_STR);
$stmt_insert->execute();
After this piece of code i'm displaying a text which displays. Also i checked for errors with print_r($db->errorInfo()); but no error is displaying. Also tried try - catch but nothing.
I entered manually from phpMyAdmin a row and it works.
Where am I wrong ? I checked the code 10 times and it's perfect.
update
i found an error in the log of the server exactly where i do ->execute
[11-Oct-2012 14:48:15] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 ''event_id', 'artist_id', 'event_title', 'date', 'event_text', 'event_start', 'ev' at line 1' in /home/cubeworx/public_html/electronicdancemusic.net/MYArtist/admin/list_events.php:527 Stack trace:
0 /home/cubeworx/public_html/electronicdancemusic.net/MYArtist/admin/list_events.php(527): PDOStatement->execute()
1 {main}
thrown in /home/cubeworx/public_html/electronicdancemusic.net/MYArtist/admin/list_events.php on line 527