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 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM