我是 PHP 新手,正在创建一个论坛。除了一个文件 add_topic.php 之外,所有文件都有效。
它给我一个错误提示:
Parse error: syntax error, unexpected T_CLASS in /home/a3885465/public_html/add_topic.php on line 25
我知道这可能是在线:
}
else{
echo "ERROR";
}
mysql_close();
但为了以防万一,整个代码都在下面。
如果您有任何想法,我们将不胜感激,谢谢!
add_topic.php 的代码
$host=""host"";
$username="username";
$password="password";
$db_name ="database_name";
$tbl_name="forum_question";// Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// get data that sent from form
$topic= $_POST['topic'];
$detail= $_POST['detail'];
$name= $_POST['name'];
$email= $_POST['email'];
$datetime=date("d/m/y h:i:s");//create date time
$sql="INSERT INTO $tbl_name(topic, detail, name, email, datetime)VALUES('$topic',
'$detail', '$name', '$email', '$datetime')";
$result=mysql_query($sql);
if($result){
echo "Successful<BR>";
echo "<a href=main_forum.php>View your topic</a>";
else{
echo "ERROR";
}
mysql_close();
?>
最佳答案
加上: 你“双引号主机。
$host=""host""; // Host name
替换为
$host="host"; // Host name
但严肃地说:您可能应该为自己准备一个像样的 IDE!
关于PHP 解析错误 : syntax error, 意外的 T_CLASS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4553401/