gpt4 book ai didi

php - 语法错误,意外的 T_ENCAPSED_AND_WHITESPACE,需要 T_STRING 或 T_VARIABLE 或 T_NUM_STRING

转载 作者:IT王子 更新时间:2023-10-28 23:56:30 35 4
gpt4 key购买 nike

<分区>

我已经盯着这段代码看了好几个小时了,我不知道我的错误在哪里。我知道这种语法错误通常是由于大括号缺失或不当或单引号/双引号出现问题而出现的,我不确定我的代码中是否存在任何错误。我现在只是想修复我的语法,这样我就可以让代码完全编译。任何帮助将非常感激。这是我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Add to and Read from the Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>

<?php
function print_form() {
echo <<<END
<form action="$_SERVER[PHP_SELF]" method="post">

<h3>Please put your comments below.</h3>

<input type="hidden" name="stage" value="process" >
<p>Name:</p>
<input type="text" size="30" name="WholeName" />
<p>Comment:</p>
<input type="text" size="200" name="Comment" />

<input type ="submit" value ="Submit" >
</form>
END;

}
function process_form() {

print "<p>adding comment...</p>";

$Name = $_POST['WholeName'];
$Comment = $_POST['Comment'];

if( preg_match("^[a-zA-Z]+$", $Name)) {
if( preg_match("^[a-zA-Z0-9]_\-\'[.?!]+$", $Comment)) {
$sql = "insert into comments1 values (
'$Name',
'$Comment')";
$result = mysql_query($sql) or die("Mysql query failed");
} else {
print "invalid name";
}
} else {
print "invalid characters";
}

}

$db = mysql_connect("", "", "");
if (!$db) {
print "Error - Could not connect to mysql";
exit;
}

$er = mysql_select_db("");
if (!$er) {
print "Error - Could not connect to comments1 database";
exit;
}

if (isset($_POST['stage']) && ('process' == $_POST['stage'])) {
process_form();
} else {
print_form();
}

?>

</body>
</html>

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com