Forums

Get URL not getting results

rstevens 26 Sep, 2012
Why does this returns results...

<?php 
	$database = JFactory::getDBO();

$ID = $_GET['ID']; // get var from URL

$query = "SELECT * from bridge_AgProduction2010 WHERE ID = $ID"; 
$result = mysql_query($query);
$row = mysql_fetch_array($result);

$County = $row['County'];


And this does not...

<?php 
	$database = JFactory::getDBO();

$Cty = $_GET['County']; // get var from URL

$query = "SELECT * from bridge_AgProduction2010 WHERE County = '$Cty'"; 
$result = mysql_query($query);
$row = mysql_fetch_array($result);

$County = $row['County'];
GreyHead 27 Sep, 2012
Hi rstevens ,

At a guess - because County isn't included in the calling URL ??? There's not much information here to make any other diagnosis.

Bob
rstevens 08 Oct, 2012
I bought you a beer for your time...

I included County in the calling URL...

index.php?option=com_chronocontact&chronoformname=CountyBridgeQuery&County=Adams

If I use a similar URL and get the ID instead of the County, I get a result

index.php?option=com_chronocontact&chronoformname=CountyBridgeQuery&ID=1

The database has 92 counties starting with the first one named Adams, which also has the ID of 1.

I will buy you a six pack if you can help me figure out what should be a simple problem to resolve, but I am obviously missing something.
GreyHead 09 Oct, 2012
Hi rstevens,

Which version of ChronoForms are you using?
You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6/1.7/2.5.

If it is CFv4 then please try this:
<?php
$db =& JFactory::getDBO();
$query = "
  SELECT * 
    FROM `bridge_AgProduction2010` 
    WHERE `County` = '{$form->data['County']}' ;
";
$db->setQuery($query);
$result = $db->loadArray();

$County = $result['County'];
. . .
?>

Bob
rstevens 09 Oct, 2012
Thanks for the suggestion, but I discovered the problem. All the database tables I was working with had the county name written as a title. The table giving me problems had the county name in all caps.
This topic is locked and no more replies can be posted.