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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.