dongyi7966 2013-08-07 07:53
浏览 38
已采纳

php代码没有执行。 已检查配置文件

I have some php code in a seperate file and its being called using javascript. But the php code isnt working. instead its just putting the code in the div. Like the full code is in the div. how can i make this php code execute

My javascript function looks like this:

function checklogin(){
    var xmlhttp;
    if (window.XMLHttpRequest)
      {
      xmlhttp=new XMLHttpRequest();
      }
     xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
          if(xmlhttp.responseText='FAILED')
            {alert('failed');};
        }
      }

      var Usrname
      Usrname=document.getElementById("edtLoginUsername").text;
    xmlhttp.open("GET","DatabaseFunctions.php?Username="+Usrname,true);
    xmlhttp.send();};

AND MY PHP Code look like this:

<?php
      $myServer = "example.com";
      $myUser = "dbuser";
      $myPass = "dbpass";
      $myDB = "efarm"; 

      //connection to the database
      $dbhandle = mssql_connect($myServer, $myUser, $myPass)
        or die("Couldn't connect to SQL Server on $myServer"); 

      //select a database to work with
      $selected = mssql_select_db($myDB, $dbhandle)
        or die("Couldn't open database $myDB"); 

      //declare the SQL statement that will query the database
      $query = "SELECT COUNT(*) FROM Users WHERE Username=myQuoteString('$_GET(USERNAME)')'"; 

      //execute the SQL query and return records
      $result = mssql_query($query);

      echo 'FAILED';
      //close the connection
      mssql_close($dbhandle);
      ?>

i have already checked my httpd.conf file and checked that the php is installed and configured

  • 写回答

2条回答 默认 最新

  • doushan15559 2013-08-07 07:59
    关注

    Check your MS SQL Connection and use $_GET['Username'] in place of $_GET(USERNAME)

     $query = "SELECT COUNT(*) FROM Users 
             WHERE Username='".$_GET['Username']."'"; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入