为何无法插入记录? $sql="INSERT INTO wyx_class (wyx_classname) VALUES ('$classname')";$classname = $_POST['classname']. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <form method="post" action="<?php echo $PATH_INFO?>">少了分号<form method="post" action="<?php echo $PATH_INFO;?>"> $classname = $_POST['classname']加上这句就可以了 if($submit)这里改成 if($_POST['submit'])试下 <?phpif($submit){//处理表格输入$db=mysql_connect("localhost","root","dirdir");mysql_select_db("wyx",$db);$sql="INSERT INTO wyx_class (wyx_classname) VALUES (''.$_POST['classname'].'')";$result=mysql_query($sql);echo "OK!\n";}else{//显示表格?> <?php if($submit){ //处理表格输入 $db=mysql_connect("localhost","root","dirdir"); mysql_select_db("wyx",$db); $sql="INSERT INTO wyx_class (wyx_classname) VALUES (''.$_POST['classname'] .'')"; $result=mysql_query($sql); echo "OK!\n"; }else{ //显示表格 ?> 变量POST过去可以用$_POST['submit'],$_POST['classname']获得,不能直接用的 给你详细的改一下<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>增加栏目</title><style type="text/css"><!--.STYLE1 { color: #FFFFFF; font-weight: bold;}--></style></head><body><?phpif($$_POST['submit']){//处理表格输入$db=mysql_connect("localhost","root","dirdir");mysql_select_db("wyx",$db);$classname = $_POST['classname'];$sql="INSERT INTO wyx_class (wyx_classname) VALUES ('$classname')";$result=mysql_query($sql);echo "OK!\n";}else{//显示表格?><form method="post" action="<?php echo $PATH_INFO?>"> <table width="300" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#666666"> <tr> <td align="center" bgcolor="#666666" class="STYLE1">增加栏目</td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input name="classname" type="text" id="classname" /></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" value="提交" /></td> </tr> </table></form><?php}//end if,if结束?></body></html> if($$_POST['submit']){多了个$LZ测试一下吧 啥也别说了,根本没POST,没接数据,怎么插入数据 <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>增加栏目</title><style type="text/css"><!--.STYLE1 { color: #FFFFFF; font-weight: bold;}--></style></head><body><?phpif(!empty($_POST['classname']) && $_SERVER['REQUEST_METHOD'] == 'POST') {//处理表格输入$db=mysql_connect("localhost","root","dirdir");mysql_select_db("wyx",$db);$classname = $_POST['classname'];$sql="INSERT INTO wyx_class (wyx_classname) VALUES ('$classname')";$result=mysql_query($sql);echo "OK!\n";}else{//显示表格?><form method="post" action="<?php echo $PATH_INFO?>"> <table width="300" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#666666"> <tr> <td align="center" bgcolor="#666666" class="STYLE1">增加栏目</td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input name="classname" type="text" id="classname" /></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" value="提交" /></td> </tr> </table></form><?php}//end if,if结束?></body></html> 今天第一次正式面试,问几道面试题。 ocilogon() function.ocilogon ocienvnlscreate() failed 谁有文件上传的代码啊 TAT 邮件群发问题 初级PHP问题 帮帮忙看看为什么不能实例化类呢 问个include大文件的问题 怎样做论坛和BBS? 数据库出错问题,望各位予以指教! 我的静态页面,狂慢!大家帮我看一下,用来参加网页评比的!(先送50分) PHP修改图片EXIF信息失败 III数组处理问题 检测浏览器类型?
少了分号
<form method="post" action="<?php echo $PATH_INFO;?>">
$classname = $_POST['classname']加上这句就可以了
if($submit){
//处理表格输入
$db=mysql_connect("localhost","root","dirdir");
mysql_select_db("wyx",$db);
$sql="INSERT INTO wyx_class (wyx_classname) VALUES (''.$_POST['classname']
.'')";
$result=mysql_query($sql);
echo "OK!\n";
}else{
//显示表格
?>
<?php
if($submit){
//处理表格输入
$db=mysql_connect("localhost","root","dirdir");
mysql_select_db("wyx",$db);
$sql="INSERT INTO wyx_class (wyx_classname) VALUES (''.$_POST['classname']
.'')";
$result=mysql_query($sql);
echo "OK!\n";
}else{
//显示表格
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>增加栏目</title>
<style type="text/css">
<!--
.STYLE1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
if($$_POST['submit']){
//处理表格输入
$db=mysql_connect("localhost","root","dirdir");
mysql_select_db("wyx",$db);
$classname = $_POST['classname'];
$sql="INSERT INTO wyx_class (wyx_classname) VALUES ('$classname')";
$result=mysql_query($sql);
echo "OK!\n";
}else{
//显示表格
?>
<form method="post" action="<?php echo $PATH_INFO?>">
<table width="300" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#666666">
<tr>
<td align="center" bgcolor="#666666" class="STYLE1">增加栏目</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="classname" type="text" id="classname" /></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" value="提交" /></td>
</tr>
</table>
</form>
<?php
}//end if,if结束
?>
</body>
</html>
多了个$LZ测试一下吧
没接数据,怎么插入数据
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>增加栏目</title>
<style type="text/css">
<!--
.STYLE1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
if(!empty($_POST['classname']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
//处理表格输入
$db=mysql_connect("localhost","root","dirdir");
mysql_select_db("wyx",$db);
$classname = $_POST['classname'];
$sql="INSERT INTO wyx_class (wyx_classname) VALUES ('$classname')";
$result=mysql_query($sql);
echo "OK!\n";
}else{
//显示表格
?>
<form method="post" action="<?php echo $PATH_INFO?>">
<table width="300" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#666666">
<tr>
<td align="center" bgcolor="#666666" class="STYLE1">增加栏目</td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><input name="classname" type="text" id="classname" /></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" value="提交" /></td>
</tr>
</table>
</form>
<?php
}//end if,if结束
?>
</body>
</html>