<?php
extract($_REQUEST);
if(isset($subject)&&isset($body)){
if( mysql_connect("localhost","root","")){
mysql_select_db("test");
mysql_query("INSERT INTO message (subject,body) VALUE ('$subject','$body')");
$status="Message <i>$subject</i>has been posted<br/><br/>";}
else{
echo "hello world";
}
}
?>
<html>
<body>
<?php $str="hello"; ?>
<h2><?=$str?></h2>
<h1>Post a Message</h1>
<strong><?=$status?></strong>
<form action="<?=$_SERVER['PHP_SELF']?>">
Subject <input type="text" name="subject" size="35">
<br/><br/>
<textarea name="body" cols="40" rows="15"></textarea>
<br/><br/>
<input type="submit" value="Post">
</form>
</body>
</html>
和预期的有点不符合
应该是服务器没弄好,建议用phpstudy集成环境服务器,自带phpmyadmin数据库,直接这样连接就行了
按下提交按钮之后,谷歌出现上述情况。数据库里面的表没变化。
参数应该要用.连接,格式应该是 双引号.$参数.双引号
mysql_query("INSERT INTO message (subject,body) VALUE ('".$subject'.",'".$body."')");
500错误,服务器错误
ini_set("display_errors", "On");
加上这行先查看是什么错误