0

Good afternoon,

I'm hoping you guys can help me out with a simple problem. I am working on my first AJAX powered app, and I'm having a problem with the PHP portion. I am passing a value "q" from my app, that should return a Country name. Instead, I get a Resource id #3. My echo commands for $q and $sql are correct, and the generated query returns the proper result in MySQL query.

What am I missing?

$q = $_GET["q"];

$host="localhost";
$user="root";
$password="******";

$connection=mysql_connect($host,$user,$password);
$db=mysql_select_db("******",$connection)
or die (mysql_error());

$sql="SELECT Country FROM country WHERE CountryID = '" . $q . "'";
$result=mysql_query($sql)
	or die(mysql_error());

echo $result . "<br />";
echo $q . "<br />";
echo $sql;

Sample result:
Resource id #3
0000000003
SELECT Country FROM country WHERE CountryID = '0000000003'

Thank you!!!

Eric

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by kibosh
0

Perfect. That did it!

I changed:

echo $result;

to:

$Countryrow = mysql_fetch_assoc($result);
echo $Countryrow["Country"];

Thanks for the help!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.