codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  $_GET not working  Neethusha at 18:58 on Friday, March 19, 2010
 

i have an XMLHttpRequest.The request passes a parameter to my php server code in /var/www. But i cannot seem to be able to extract the parameter back at the server side. below i have pasted both the codes:

javascript:

function getUsers(u)
{
alert(u);//here u is 'http://start.ubuntu.com/9.10'
xmlhttp=new XMLHttpRequest();
var url="http://localhost/servercode.php"+"?q="+u;

xmlhttp.onreadystatechange= useHttpResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function useHttpResponse()
{

if (xmlhttp.readyState==4 )
{
var response = eval('('+xmlhttp.responseText+')');
for(i=0;i<response.Users.length;i++)
alert(response.Users.UserId);

}
}


servercode.php:

<?php
$q=$_GET["q"];
//$q="http://start.ubuntu.com/9.10";
$con=mysql_connect("localhost","root","blaze");
if(!$con)
{die('could not connect to database'.mysql.error());
}
mysql_select_db("BLAZE",$con) or die("No such Db");
$result=mysql_query("SELECT * FROM USERURL WHERE URL='$q'");

if($result == null)
echo 'nobody online';
else
{
header('Content-type: text/html');
echo "{\"Users\":[";
while($row=mysql_fetch_array($result))
{
echo '{"UserId":"'.$row[UsrID].'"},';
}
echo "]}";
}
mysql_close($con);
?>


this is not giving the required result...although the commented statement , where the variable is assigned explicitly the value of the argument works...it alerts me the required output...but somehow the GET method's parameter is not reaching my php or thats how i think it is....pls help....


  Re: $_GET not working  basilas at 11:51 on Monday, May 31, 2010
 

The AJAX code you written, I found several errors.... if you are really interested, I can help you, but you need to reply soon, I am telling this simply because this post is 3 month old, don't mind please....

  Re: $_GET not working  cindyone at 21:16 on Saturday, July 17, 2010
 

Hey Basislas, can you please post the errors? I have been staring at this code for 20 minutes and cannot find what you mite be seeing.


-----------------------
-----------------------
things to do in pa








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Downloading a file using http
•  Script to save iframe source (cookie?)
•  Re: orphan files (owner account deleted in linux but files exists)
•  Re: Need hosted_button_id value from PayPal generated code
•  Re: Save up to 80% on SSL Certificates, RapidSSL Certificate @ $ 11.00/yr.
•  Re: need to enable a text area when the dropdown menus value is more than 0
•  Re: Run a .bat file from VB
•  Handling large datasets in charts quickely
•  Re: How to concatenate a string and a variable using perl?


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010