Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.