Greetings

First, as a relative newbie to Drupal I am amazed at what I have been able to do with a number of sites and a limited knowledge of PHP :)

I have what I suspect is a simple problem and I apologise in advance if it is covered elsewhere ... altho I have searched this forum and googled extensively.

I am migrating a database driven app which displays database driven info based on a id value ie show?id=1068.

How do I access the querystring value $id from a PHP script within Drupal?

My thanks in advance.

Comments

dldege’s picture

$value = $_GET['id'];

dLd

david.archibald’s picture

I'm not sure whether to be grateful or embarassed or both!

But thanks for helping a newbie - it is appreciated.

dldege’s picture

No problem - I didn't know how to do it either when I first started with PHP/Drupal.
dLd

minoroffense’s picture

For Drupal 7, it seems this is the proper way to get query string parameters

http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ge...

--
Mathew Winstone
CEO/Co-Founder
Coldfront Labs Inc.

jop007’s picture

I found a function drupal_get_query_parameters which returns an array (value pairs). Where must I put this general code. Make one module and call it library?

John

ronrons’s picture

This is a time saver, thanks for the info.

dotmundo’s picture

This function does not do any sanitization does it?

jaypan’s picture

No, it doesn't.

Contact me to contract me for D7 -> D10/11 migrations.

pratip.ghosh’s picture

You can also try $_SERVER['QUERY_STRING']

-- Pratip Ghosh

dotmundo’s picture

Hey David,

Make sure you sanaitize $_GET or $_POST retrievals. Just saying.

jaypan’s picture

Considering David made this thread 8 years ago, he's probably already done that, or learned the hard way.

Contact me to contract me for D7 -> D10/11 migrations.