修改数据表,,我是这样写的,,但是没用,,一打开就自动改了<?
include ("conn.php");
?><html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head><body>
<script language="JavaScript" type="text/JavaScript">
function ss(){
<?
//修改信息
$sSQL="update user_info  set client_ip='211.162.35.249' where user_name ='4b687bb11'";

 
?>
}
</script>
<form name="form1" method="post" action="">
  <div align="center"><input type="button" name="Button" value="Button" onClick="ss()">
  </div>
</form>
</body>
</html>

解决方案 »

  1.   

    <script language="JavaScript" type="text/JavaScript">
    function ss(){
    <?
    //修改信息
    $sSQL="update user_info  set client_ip='211.162.35.249' where user_name ='4b687bb11'";
    $result1=mysql_db_query("sdata",$sSQL,$cn);
    ?>}
    </script>
      

  2.   

    如果你想在JS下面操作SQL语句,把这个JS函数写在一个单独的文件下面,再在这个页面调用不就可以了??
      

  3.   

    这样是不行的
    给你个例子看看,可以达到你的要求。
    <input name="sta2"  type="button" id="sta2" onClick="sendreceive();" value="send email for received"><iframe id="sendframe" name="sendframe" src="about:blank" width="0" height="0" scrolling="no"></iframe>
    <form action="../sendreceive.php" method="post" name="receive" id="receive" target="sendframe">
      <input name="r_account" type="hidden" id="r_account" value="">
      <input name="r_unit" type="hidden" id="r_unit">
      <input name="r_amount" type="hidden" id="r_amount">
      <input name="r_email" type="hidden" id="r_email" value="">
      <input name="r_status" type="hidden" id="r_status">
      <input name="rc_email" type="hidden" id="rc_email">
      <input name="receivedate" type="hidden" id="receivedate">
    </form>
    <script>
    function sendreceive()
    {
     document.all("r_unit").value=document.all("textfield8").value;
     document.all("r_amount").value=document.all("textfield9").value;
     document.all("r_status").value=document.all("textfield10").value;
     document.all("rc_email").value=document.all("textfield11").value;
     document.all("receivedate").value=document.all("textfield12").value;
     document.all("sta2").value="sending email...";
     document.receive.submit();
    }
    </scrip>
    再在sendreceive.php写你的修改数据库语句。
      

  4.   

    看起来他好象把 SERVER 端执行的脚本  和  CLIENT端执行的脚本弄混了。
      

  5.   

    使用一个隐藏frame 例如abc,<form target="abc">,在target实现提交就足够了,不提交怎么能改?
    你不给钱也买不到东西啊?
      

  6.   

    用com就行。
    叫“无刷新技术”的。
      

  7.   

    function ss()
    {
    }
    这里不会有内容的,当你页面读取后,其实是服务器已经执行了返回的东西。写一个隐藏frame吧。
      

  8.   

    用com,用PHP干麻。呵呵
    经典!如果用com,那就应该考虑asp
      

  9.   

    当然不行,php是在服务器端解析的js是在客户端解析的,服务器先解析完了
    <?
    //修改信息
    $sSQL="update user_info  set client_ip='211.162.35.249' where user_name ='4b687bb11'";
    $result1=mysql_db_query("sdata",$sSQL,$cn);
    ?>
    才将改页发送到客户端,IE才解析function ss(),此时php的sql代码已经执行完了你可这样:
    在页面上写一个隐藏表单<form name="form2" target="***.php" style="display:none"></form>
    点击按钮后在ss()中提交该隐藏表单document.form["form2"].submit()
    然后把数据库操作代码写在***.php中就可以了