我无法在函数中使用mysql查询.我不明白为什么会这样:
$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);
Run Code Online (Sandbox Code Playgroud)
但这不是:
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);
}
Run Code Online (Sandbox Code Playgroud)
当然,我有一个与db的连接,我正在调用该函数.我尝试用一些回声调试,我发现该函数停止了ant mysql_query,但我不明白为什么.