我很難弄清楚這段代碼有什麼問題。我嘗試了很多變化,但仍然在這一行中出現錯誤:這裏的PHP語法有什麼問題?
$query= "INSERT INTO publish (name, email, title, content)" .
"VALUES ('$row['Name']','$row['Email']',$row['title'],$row['content'])";
什麼可能是錯誤的?
這裏的其餘代碼:
<?php
// connect to the database
include('config2.php');
// check if the 'id' variable is set in URL, and check that it is valid
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
// get id value
$id = $_GET['id'];
$dbc = mysqli_connect('localhost', 'x', 'x', 'x')
or die('Error');
$name = $row['Name'];
$email = $row['Email'];
$title = $row['title'];
$content = $row['content'];
$result = mysql_query("select *stories WHERE id=$id")
or die(mysql_error());
$row = mysql_fetch_array($result);
$query= "INSERT INTO publish (name, email, title, content)" .
"VALUES ('$row['Name']','$row['Email']',$row['title'],$row['content'])";
or die('Error querying database.');
mysqli_close($dbc);
}
?>
錯誤消息: 「解析錯誤期待標識符(T_STRING) '或變量(T_VARIABLE)' 或數(T_NUM_STRING)「」
如果你能在這條線上顯示其餘的代碼,比如'$ row' ....是什麼? – Darren
不確定,但嘗試在VALUES –
之前添加空格以及錯誤消息是什麼? –