mysql - 语法错误,运行 php7 时文件意外结束

标签 mysql php-7.1

在过去的一个小时里,我似乎无法理解我的代码出了什么问题,我是编码新手,我做了一些研究并打开了短标签,但我似乎仍然遇到了意外的文件结束错误。任何帮助都会很棒

<?php

include("config.php");

if($submit)
{//begin of if($submit).

// Set global variables to easier names
$title = $_POST['title'];
$text1 = $_POST['text1'];
$text2 = $_POST['text2'];


//check if (title) field is empty then print error message.
if(!$title){ //this means If the title is really empty.
echo "Error: News title is a required field. Please fill it.";
exit(); //exit the script and dont do anything else.
}// end of if
//run the query which adds the data gathered from the form into the database
$result = mysqli_query("INSERT INTO news (title, dtime, text1, text2)
VALUES ('$title',NOW(),'$text1','$text2')",$connect);
//print success message.
echo "<b>Thank you! News added Successfully!<br>You'll be redirected to Home Page after (4) Seconds";
echo "<meta http-equiv=Refresh content=4;url=index.php>";
}//end of if($submit).


// If the form has not been submitted, display it!
else
{//begin of else

?>
<br>
<h3>::Add News</h3>

<form method="post" action="<?php echo $PHP_SELF ?>">
Title: <input name="title" size="40" maxlength="255">
<br>
Text1: <textarea name="text1" rows="7" cols="30"></textarea>
<br>
Text2: <textarea name="text2" rows="7" cols="30"></textarea>
<br>
<input type="submit" name="submit" value="Add News">
</form>
<?
}//end of else

?>

最佳答案

我也有同样的经历。 我到处都有 '

关于mysql - 语法错误,运行 php7 时文件意外结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51912359/

相关文章:

php - 将 Plesk 的 PHP 版本更改为 PHP 7

php - Homebrew PHP 似乎没有链接。 - 代客

php - 在MySql数据库中按相等值统计记录数

php - 升级 PHP/MySQL 后 WordPress 管理仪表板挂起

MySql 更新。过程结果和phpmyadmin sql之间的区别

MySQL - 在 varchar 中存储长度为 1000

mysql - Groovy:解析具有特定扩展名的文件以导入 MySQL,然后将其重命名为 *.bak

php - 如何在一次连接三个表的同时对列求和

mysql - 快速 rand() 顺序搜索