Jump to content

not returning any values


kenny22

Recommended Posts

First post and very much a newbie

 

my html page has this script in header, however when i debug the line

http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true);

returns a non defineded http, i've checked my  "getagentids.php" file but cant see why its returning 0

i have included my getagentids.php script below

 

 

Html page

 

<script>


var url = "getagentids.php?param=";




function getagentids() {
var idValue = document.getElementById("agid").value;
var myRandom = parseInt(Math.random()*99999999);  // cache buster
http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}

function handleHttpResponse() {
if (http.readyState == 4) {
  results = http.responseText.split(",");
  document.getElementById('agfn').value = results[0];
  document.getElementById('agsal').value = results[1];
  document.getElementById('agtel').value = results[2];
  document.getElementById('agid').value = results[3];
  }
}  

 

 

getagentids.php

 

$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);



if(strlen($param)>0){
$result = mysql_query("SELECT * FROM contact 
     	WHERE ContactID LIKE '$param%'");

if(mysql_num_rows($result)==1) {
while($myrow = mysql_fetch_array($result)){
   $agentname = $myrow["ContactFullName"];
   $agenttel = $myrow["ContactTel"];
   $agentsal = $myrow["ContactSalutation"];
   $agentid = $myrow["ContactID"];
   $textout .= $agentname.",".$agentsal.",".$agenttel.",".$agentid;
}
} else {
$textout=" , , ,".$param;
}
}
echo $textout;

 

 

Link to comment
https://forums.phpfreaks.com/topic/227151-not-returning-any-values/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.