Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php代码不在同一页面中工作_Php - Fatal编程技术网

php代码不在同一页面中工作

php代码不在同一页面中工作,php,Php,当代码是单独的文件时可以工作,但当包含在同一个html文件中时不能工作 下面给出了完整的代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta htt

当代码是单独的文件时可以工作,但当包含在同一个html文件中时不能工作

下面给出了完整的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?php
$connect=mysqli_connect("127.0.0.1","root","notmention","mysite");
if (mysqli_connect_errno($connect))
  {
  $txt="Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $txz="s";
?>
</head>
<body background="images/background.PNG">
<div align="center">
<form action="register.html" enctype="multipart/form-data" method="post"  >
<span style="color:#399">Create Account</span><br />
<input type="text" name="username" placeholder="Username" /><br />
<input type="text" name="password" placeholder="password" /><br />
<input type="text" name="email" placeholder="email" /><br />
<input type="submit" value="Submit"  /><br />
</form>
</div>
<div><?php echo $txt ?></div><br />
<div><?php echo $txz ?></div><br />

</body>
</html>

无标题文件
创建帐户







您需要使用.php扩展名保存它,而不是使用.html

我希望您使用的是
.php
文件?我的错误,它现在工作了: