//这里是conn.php
<?
$conn = mysql_connect("localhost","root","123456") or die ("数据库连接错误");
mysql_select_db("gbook",$conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>1 <?php
2 include("conn.php");
3
4 if($_POST['submit']){
5 echo $sql = "INSERT INTO `ibog_leveword` ( `id` , `user` , `title` , `content` , `time` ) ".
6 "VALUES ('', '$_POST[user]', '$_POST[title]', '$_POST[content]', NOW( ) )";
7 ?>
8 <form action="add.php" method="post">
9 <b>Your name:</b><BR><INPUT name="user" type="text" size="55"><BR>
10 <b>Your name:</b><BR><INPUT name="title" type="text" size="55"><BR>
11 <b>Your comment:</b><BR><TEXTAREA name="content" rows=10 cols=55 wrap=virtual></TEXTAREA><BR>
12 <INPUT name="submit" type="submit" value="Post your comments">
13 </form>这里是提示错误问题
Parse error: parse error, unexpected $end in D:\AppServ\www\ibog\add.php on line 13我是提交到本页,但是这段代码写不进MYSQL,
<?
$conn = mysql_connect("localhost","root","123456") or die ("数据库连接错误");
mysql_select_db("gbook",$conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>1 <?php
2 include("conn.php");
3
4 if($_POST['submit']){
5 echo $sql = "INSERT INTO `ibog_leveword` ( `id` , `user` , `title` , `content` , `time` ) ".
6 "VALUES ('', '$_POST[user]', '$_POST[title]', '$_POST[content]', NOW( ) )";
7 ?>
8 <form action="add.php" method="post">
9 <b>Your name:</b><BR><INPUT name="user" type="text" size="55"><BR>
10 <b>Your name:</b><BR><INPUT name="title" type="text" size="55"><BR>
11 <b>Your comment:</b><BR><TEXTAREA name="content" rows=10 cols=55 wrap=virtual></TEXTAREA><BR>
12 <INPUT name="submit" type="submit" value="Post your comments">
13 </form>这里是提示错误问题
Parse error: parse error, unexpected $end in D:\AppServ\www\ibog\add.php on line 13我是提交到本页,但是这段代码写不进MYSQL,
好像没有关闭花括号。
$result=mysql_query($sql);
if($resul){
提示之类的语句.........
}
那怎么样才能写进MYSQL中呢? 具体点,拜托了!!!
<?php
include("conn.php");if($_POST['submit']){
$sql="insert into ibog_leveword ( `id` , `user` , `title` , `content` , `time` ) ".
"value ('', '$_POST[user]', '$_POST[title]', '$_POST[content]', nows( ) )";
$result=mysql_query($sql);
echo "成功";
}
?>
<form action="add.php" method="post" name="myform" onsubmit="return CheckPost();">
<b>您的用户名:</b><br><input name="user" type="text" size="55"><br>
<b>您的标题:</b><br><input name="title" type="text" size="55"><br>
<b>您的内容:</b><br><textarea name="content"></textarea><br>
<input name="submit" type="submit" value="Post your comments">
</form>
我现在加了花括号,可还是写不进MYSQL啊!!!
怎么写才能进MYSQL帮帮忙!!!!!
include("conn.php");if(isset($_POST["submit"])){
$user = trim($_POST["user"]);
$title = trim($_POST["title"]);
$content = trim($_POST["content"]);
$sql = "insert into ibog_leveword (`user` ,`title` ,`content` ,`time`) values('$user','$title','$content',nows())";
$result = mysql_query($sql);
if($result) echo 'ok';
else echo 'fail';
}
?>
if($_POST['submit']){
$sql = "INSERT INTO `ibog_leveword` ( `id` , `user` , `title` , `content` , `time` ) VALUES (NULL, '{$_POST['user']}', '{$_POST['title']}', '{$_POST['content']}', NOW() )"; $re = mysql_query($sql);
if($re){
echo '成功';
}else{
echo '失败';
}
}
第13行有问题
应该是找不到结尾的花括号
应该就是 if语句的结尾花括号没有打上的问题