kenny22 Posted February 9, 2011 Share Posted February 9, 2011 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; Quote Link to comment https://forums.phpfreaks.com/topic/227151-not-returning-any-values/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.