MySQL+PHP无法写入数据问题
//服务端部分代码:<scripttype="text/javascript">functionsubmit_check(){varxmlhttp;varttext;tt...
//服务端部分代码:
<script type="text/javascript">
function submit_check()
{
var xmlhttp;
var ttext;
ttext = document.getElementById("ttext").innerHTML;
document.getElementById("t_but").disabled=true;
document.getElementById("t_but").value="正在发送...";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if(xmlhttp.responseText==1)
{
document.getElementById("t_but").disabled=false;
document.getElementById("t_but").value="发表";
document.getElementById("error").innerHTML=xmlhttp.responseText;
}else{
document.getElementById("t_but").disabled=false;
document.getElementById("t_but").value="发表";
document.getElementById("error").innerHTML=xmlhttp.responseText;
return false;
}
}
}
xmlhttp.open("POST","./sendm.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("ttext="+document.getElementById("ttext").innerHTML+"&wd="+<?php echo $wd;?>);
return false;
}
</script>
<?
php session_start();
$wd = $_POST["wd"];
$ttext = $_POST["ttext"];
$username = $_SESSION['loginname'];
$con = mysql_connect("a","b","c");
mysql_select_db("d", $con);
$result = mysql_query("SELECT * FROM Tieba WHERE Tieid='$wd'");
$row = mysql_fetch_array($result);
$ba = $row['Ba'];
$name = $row['Name'];
$lou = 1;
$nowtime = date();
mysql_query("INSERT INTO Tieba (Tieid, Time, Ba, Name, Username, Message, Lou) VALUES ('$wd', '$nowtime', '$ba', '$name', '$username', '$ttext', '$lou')");
echo ("1");
}
?> 展开
<script type="text/javascript">
function submit_check()
{
var xmlhttp;
var ttext;
ttext = document.getElementById("ttext").innerHTML;
document.getElementById("t_but").disabled=true;
document.getElementById("t_but").value="正在发送...";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
if(xmlhttp.responseText==1)
{
document.getElementById("t_but").disabled=false;
document.getElementById("t_but").value="发表";
document.getElementById("error").innerHTML=xmlhttp.responseText;
}else{
document.getElementById("t_but").disabled=false;
document.getElementById("t_but").value="发表";
document.getElementById("error").innerHTML=xmlhttp.responseText;
return false;
}
}
}
xmlhttp.open("POST","./sendm.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("ttext="+document.getElementById("ttext").innerHTML+"&wd="+<?php echo $wd;?>);
return false;
}
</script>
<?
php session_start();
$wd = $_POST["wd"];
$ttext = $_POST["ttext"];
$username = $_SESSION['loginname'];
$con = mysql_connect("a","b","c");
mysql_select_db("d", $con);
$result = mysql_query("SELECT * FROM Tieba WHERE Tieid='$wd'");
$row = mysql_fetch_array($result);
$ba = $row['Ba'];
$name = $row['Name'];
$lou = 1;
$nowtime = date();
mysql_query("INSERT INTO Tieba (Tieid, Time, Ba, Name, Username, Message, Lou) VALUES ('$wd', '$nowtime', '$ba', '$name', '$username', '$ttext', '$lou')");
echo ("1");
}
?> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询