Jump to content

Using variables passed in the URL to construct a query


Jellicle

Recommended Posts

Chaps

 

I'm trying to run a query constructed from values passed in a URL. The URL looks like this:

 

http://domain.com/scripts/listrecords.php?state=NT&suburb=Darwin

 

In my php file I do this:

 

$query = "select * from dogs where state = '".mysql_real_escape_string($_GET['state'])."' AND suburb = '".mysql_real_escape_string($_GET['suburb'])."';

When I do just:

 

$query = "select * from dogs where state = '".mysql_real_escape_string($_GET['state'])."'

 

It works. But when I add the second variable it doesn't.

 

What am I doing wrong?

 

Jellicle

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.