I'm having trouble getting a mysql query to work within a function. I don't understand why this works:
$datetime = date('m/d/Y h:i:s a', time());
$query = "INSERT INTO 1_posts (title_post, time_post, key_words_post, content_post) VALUES ('$title2', '$datetime', '$keywords2', '$text2')";
mysql_query($query, $con);
but this does not:
function insert_post($title2, $keywords2, $text2)
{
$datetime = date('m/d/Y h:i:s a', time());
$query = "INSERT INTO 1_posts (title_post, time_post, key_words_post, content_post) VALUES ('$title2', '$datetime', '$keywords2', '$text2')";
mysql_query($query, $con);
}
Of course, I have a connection to the db, and I am calling the function. I tried to debug with some echos and I found out that the function stops ant mysql_query, but I have no idea why.