如何清空内存? 你是本页直接调用的吧不是内存的缘故,是页面url参数你可以重新定向if($submit){ //处理函数; header("location:$PHP_SELF"); } 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是我的源程序,大家看该怎么改:<html><head><title>在线投票!</title></head><body bgcolor="#0099FF" text="#666666"><div align="center"><form action="$PHP_SELF" method="get" name="form"> <table width="75%" border="0" cellspacing="1" bgcolor="#FFFF00"> <tr bgcolor="#0099FF" align="center" valign="middle"> <td width="20%" height="30">添加投票项目</td> <td width="65%" height="30"> <input type="text" name="item0" size="50%"> </td> <td width="15%" height="30"> <input type="submit" name="Submit" value="添加"> </td> </tr> </table> </form> <br><?$connect=mysql_connect("localhost","root","");mysql_select_db("carmoon",$connect);$time=date("Y-m-d.G:i:s");$query=mysql_db_query('select * from vote',$connect);$query=mysql_query("insert into vote(item,time) values('$item0','$time')",$connect);mysql_close($connect);?><?header("location:$PHP_SELF");?> <table width="75%" border="0" cellspacing="1" bgcolor="#FFFF00" cellpadding="1"> <tr bgcolor="#0099FF" valign="bottom"> <td align="center" height="17"> 调查项目 </td> <td align="center" height="17">开始时间 </td> <td align="center" height="17"> 投票 </td> </tr> </table></div></body></html> 清空内存,如果我没有想错的话,在php 中执行这个函数就可以了,ob_end_clean(); ob_end_clean()是清空输出缓冲区:) <?$connect=mysql_connect("localhost","root","");mysql_select_db("carmoon",$connect);$time=date("Y-m-d.G:i:s");$query=mysql_db_query('select * from vote',$connect);$query=mysql_query("insert into vote(item,time) values('$item0','$time')",$connect);mysql_close($connect);?><?header("location:$PHP_SELF");?>偶对你这段代码表示疑义 : 不管表单是否提交,你都插入数据库,肯定不对.而且header的作用是转向,在这里似乎没有意义.改成:<?if (isset($_POST["Submit"])) // 判断是否有表单提交{$connect=mysql_connect("localhost","root","");mysql_select_db("carmoon",$connect);$time=date("Y-m-d.G:i:s");$query=mysql_db_query('select * from vote',$connect);$query=mysql_query("insert into vote(item,time) values('$item0','$time')",$connect);mysql_close($connect);}?> 关于php处理JSON的问题 php 取值---在线等 php+mysql求一问题的解决思路 广州 php高手兼职或SOHO 请问如何实现这样的统计? 有人能提供个:多项选择 的PHP代码吗?谢谢!! 有没有广州的写程序团队? 请问:如何方便,快速地抓取其他网站上的实时数据 怎样实现PHP里的当前时间显示,谁有源代码? 已经从php mysql 返回数组后如何写入div之中!求源码 如何建立文件夹 各位? 送分问题:如何通过php从mysql中得到数据?
<html>
<head>
<title>在线投票!</title>
</head>
<body bgcolor="#0099FF" text="#666666">
<div align="center">
<form action="$PHP_SELF" method="get" name="form">
<table width="75%" border="0" cellspacing="1" bgcolor="#FFFF00">
<tr bgcolor="#0099FF" align="center" valign="middle">
<td width="20%" height="30">添加投票项目</td>
<td width="65%" height="30">
<input type="text" name="item0" size="50%">
</td>
<td width="15%" height="30">
<input type="submit" name="Submit" value="添加">
</td>
</tr>
</table>
</form>
<br>
<?
$connect=mysql_connect("localhost","root","");
mysql_select_db("carmoon",$connect);
$time=date("Y-m-d.G:i:s");
$query=mysql_db_query('select * from vote',$connect);
$query=mysql_query("insert into vote(item,time) values('$item0','$time')",$connect);
mysql_close($connect);
?>
<?header("location:$PHP_SELF");?>
<table width="75%" border="0" cellspacing="1" bgcolor="#FFFF00" cellpadding="1">
<tr bgcolor="#0099FF" valign="bottom">
<td align="center" height="17"> 调查项目 </td>
<td align="center" height="17">开始时间 </td>
<td align="center" height="17"> 投票 </td>
</tr>
</table>
</div>
</body>
</html>
ob_end_clean();
$connect=mysql_connect("localhost","root","");
mysql_select_db("carmoon",$connect);
$time=date("Y-m-d.G:i:s");
$query=mysql_db_query('select * from vote',$connect);
$query=mysql_query("insert into vote(item,time) values('$item0','$time')",$connect);
mysql_close($connect);
?>
<?header("location:$PHP_SELF");?>偶对你这段代码表示疑义 : 不管表单是否提交,你都插入数据库,肯定不对.而且header的作用是转向,在这里似乎没有意义.改成:
<?
if (isset($_POST["Submit"])) // 判断是否有表单提交
{
$connect=mysql_connect("localhost","root","");
mysql_select_db("carmoon",$connect);
$time=date("Y-m-d.G:i:s");
$query=mysql_db_query('select * from vote',$connect);
$query=mysql_query("insert into vote(item,time) values('$item0','$time')",$connect);
mysql_close($connect);
}
?>