php数据 插入问题 php数据库mysql 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 action 属性规定当提交表单时,向何处发送表单数据,你提交给了show.php,而你的插入语句写在本文件里面啊 不是下面这个是<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>留言板</title><style type="text/css">a{text-decoration:none;}body h1{text-align:center;}.tr1{background-color:yellow;}.tr1 td{width:100px;}.tr2 td{height:80px;}</style><?php include_once 'conn.php'; $url = $_SERVER['REQUEST_URI']; $url = parse_url($url); $url = $url[path];?></head><body> <h1>留言查看</h1> <?php $query = mysql_query("select * from infor"); $num = mysql_num_rows($query); while ($row = mysql_fetch_array($query)){ ?> <table cellpadding="0" cellspacing="0" border="1" align="center"> <tr class="tr1"> <td>ID:<?php echo $row['id'];?></td> <td>姓名:<?php echo $row['name'];?></td> <td>标题:<?php echo $row['title'];?></td> </tr> <tr class="tr2"> <td colspan="3">内容:<?php echo $row['content'];?></td> </tr> <br> </table> <?php }?></body></html> form 的action是指定表单的处理文件,你的show.php 都没有插入语句,怎么能插入到数据库呢。 PHP插入数据信息示例//需要插入数据库的内容<form action="show.php" method="post" style="margin-top:550px;margin-left:50px;">姓名:<input type="text" name="name"><br/><br/>标题:<input type="text" name="title"><br/><br/>内容:<textarea cols="15" rows="4" name="content"></textarea><br/><br/><input value="提交" name="submit" type="submit"><input value="重置" name="reset" type="reset">//show.php页面设置插入tb_note数据库<?php$name =$_POST['name'];$title = $_POST['title'];$content= $_POST['content'];$query=mysql_query("insert into tb_note (name,title,content) values(' $name','$title’,’$content')”.$conn);if($query==true) {echo "<script>alert('上传插入成功!');window.location.href='index.php';</script>";}//CodeGo.net/Else{echo "<script language='javascript'>alert('对不起,插入失败!');history.back();</script>";}?> 因为是你当前页面操作,要么在form的action正确指向操作的文件,要么action默认为空。 写个正则表达式 用zend studio运行login.php登录后提示internal server error 有无内置函数能够得到数组特定元素之和 关于使用PHP制作仿IE工具栏管理的功能(内详有示意图) 如何判断用户是第一次访问? 正则表达式。高手入!!! 聊天室的问题 md5最多可以家几位密码 那位高人知道怎样取出远程服务器上指定目录下的文件,只要文件名就可以了! php翻译的问题!! 集成环境XAMPP安装的wordpress怎么更改外网访问IP 关于pdo引用传参,字段是不是不能当成参数传入?
不是
下面这个是
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言板</title>
<style type="text/css">
a{text-decoration:none;}
body h1{text-align:center;}
.tr1{background-color:yellow;}
.tr1 td{width:100px;}
.tr2 td{height:80px;}
</style>
<?php
include_once 'conn.php';
$url = $_SERVER['REQUEST_URI'];
$url = parse_url($url);
$url = $url[path];
?>
</head>
<body>
<h1>留言查看</h1>
<?php
$query = mysql_query("select * from infor");
$num = mysql_num_rows($query);
while ($row = mysql_fetch_array($query)){
?>
<table cellpadding="0" cellspacing="0" border="1" align="center">
<tr class="tr1">
<td>ID:<?php echo $row['id'];?></td>
<td>姓名:<?php echo $row['name'];?></td>
<td>标题:<?php echo $row['title'];?></td>
</tr>
<tr class="tr2">
<td colspan="3">内容:<?php echo $row['content'];?></td>
</tr>
<br>
</table>
<?php }?>
</body>
</html>
//需要插入数据库的内容
<form action="show.php" method="post" style="margin-top:550px;margin-left:50px;">
姓名:<input type="text" name="name"><br/><br/>
标题:<input type="text" name="title"><br/><br/>
内容:<textarea cols="15" rows="4" name="content"></textarea><br/><br/>
<input value="提交" name="submit" type="submit">
<input value="重置" name="reset" type="reset">
//show.php页面设置插入tb_note数据库
<?php
$name =$_POST['name'];
$title = $_POST['title'];
$content= $_POST['content'];
$query=mysql_query("insert into tb_note (name,title,content) values(' $name','$title’,’$content')”.$conn);
if($query==true) {echo "<script>alert('上传插入成功!');window.location.href='index.php';</script>";
}//CodeGo.net/
Else{
echo "<script language='javascript'>alert('对不起,插入失败!');history.back();</script>";
}
?>