0
我寫了這個mysql查詢,但出於一些奇怪的原因,它在phpmyadmin中工作。當我在php中運行這個查詢時,它不起作用。Mysql查詢在phpmyadmin中工作,但不是在php腳本中
MySQL的
$sql = "INSERT INTO msw_posts (user_id, user_name, title, vak, richting, type, post_date, points, views, likes, dislikes, year, keywords, discription)
VALUES ('1', 'test user', 'test', 'bio', 'aso', 'cursus', '2016-05-04', '0', '0', '0', '0', '3', 'test', 'discr')";
PHP
if (mysqli_query($dbConn, $sql)) {
echo "New record created successfully";
//uploaden en checken of upload in orde is
if(move_uploaded_file($_FILES['bestand']['tmp_name'], $dir.$file)){
header("Location: uploaden.php?type=ok");
}else{
header("Location: uploaden.php?type=failed_uploading");
}
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
謝謝你的建議或幫助!在你的字段名
'type'是[MySQL的保留字(https://開頭開發.mysql.com/doc/refman/5.6/en/keywords.html),如果不包含反引號('\''),則不能用於表或列名稱。 'year'是一個mysql保留字,同樣 –
嘗試使用'\''編寫您的字段名稱(它是Num 1鍵之前的符號)Like:'INSERT INTO msw_posts(\'user_id \',\'user_name \', ...'有時候會和現有的命令混淆 – TipuZaynSultan
@markBaker感謝您的幫助!! –