hello,
i have a html file calling this JavaScript.
var xmlHttp
function GetEmployee()
{
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{
alert("Your browser is not supported?")
}
var url="get_employee.php?"
url=url+"cmd=GetEmployee"
url=url+"&sid="+Math.random()
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function FetchComplete()
{
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("Result").innerHTML=xmlHttp.responseText
}
if(xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
{
document.getElementById("Result").innerHTML="loading"
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}catch (e)
{
try
{
xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
return xmlHttp;
}
Which works fine, however my PHP file seems not to be displaying any result, the code is here:
<?php
session_start();
if (isset($_GET["cmd"]))
$cmd = $_GET["cmd"];
else
die("You should have a 'cmd' parameter in your URL");
$con = mysql_connect("localhost","root","geheim");
if(!$con)
{
die('Connection failed because of' .mysql_error());
}
mysql_select_db("ebay",$con);
if($cmd=="GetEmployee")
{
echo "<table border='1' width='100%'>
<tr>
<th>test1</th>
<th>test2</th>
<th>test3</th>
</tr>";
$sql="select * from tblAuction";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
echo "<tr>
<td>".$row['SELLER_ID']."</td>
<td>".$row['ACCESSSTARTS']."</td>
<td>".$row['ARTICLE_NAME']."</td>
</tr>";
}
echo "</table>";
}
mysql_close($con);
?>
the php page seems to be being called, as my apache log shows:
127.0.0.1 - - [20/Nov/2008:14:29:22 +0100] "GET /Employee.html HTTP/1.1" 304 -
127.0.0.1 - - [20/Nov/2008:14:29:22 +0100] "GET /ajaxlib.js HTTP/1.1" 304 -
127.0.0.1 - - [20/Nov/2008:14:29:23 +0100] "GET /get_employee.php?cmd=GetEmployee&sid=0.7152559213961012 HTTP/1.1" 200 282
127.0.0.1 - - [20/Nov/2008:14:29:24 +0100] "GET /get_employee.php?cmd=GetEmployee&sid=0.15027097582792692 HTTP/1.1" 200 282
127.0.0.1 - - [20/Nov/2008:14:29:24 +0100] "GET /get_employee.php?cmd=GetEmployee&sid=0.24347586051168096 HTTP/1.1" 200 282
The php file works fine when called by itself.