What could make a query run fine from the command line and return the expected results, but not return results when run through the page? I get no syntax errors, just a warning for the fetch_array. It all looks good to me, I'm stumped.

I echoed all the variables immediately before the query and they hold the same values that I use from the command line and get results. I also echoed the query itself just to be sure and everything is there.

Here is the query.

$flat=("SELECT C.Latitude, C.Longitude FROM Cities C JOIN Countries Co ON Co.CountryId = C.CountryId JOIN Regions R ON R.RegionId = C.RegionId WHERE C.City = '$city' and Co.Country = '$country' and R.Region='$state'");
	while($fr = mysql_fetch_array($flat)){
		$lat = $fr['Latitude'];
		$long = $fr['Longitude']; }

Recommended Answers

All 4 Replies

<?php
/* connect select db etc */
$flat=("SELECT C.Latitude, C.Longitude FROM Cities C JOIN Countries Co ON Co.CountryId = C.CountryId JOIN Regions R ON R.RegionId = C.RegionId WHERE C.City = '$city' and Co.Country = '$country' and R.Region='$state'");
while ($fr = mysql_fetch_array(mysql_query($flat))) {
$lat = $fr['Latitude'];
$long = $fr['Longitude']; } 
/* echo $lat $long; */
?>

I dunno but there has to be a query in there doesnt there?

DOH! Okay, let's both just walk away from that one and pretend like it never happened.

DOH! Okay, let's both just walk away from that one and pretend like it never happened.

I ran it through a syntax checking editor
Syntactically the first one is correct code
each line was right in itself
It took asking my 18 year old for a hint,
he just said
"whats the query?"
and left :(

Yup, I gave myself a V8 over that one. Here's your sign 8-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.