-   Linux - Server (
-   -   Very basic php-mysql question (

rmknox 07-12-2010 10:19 AM

Very basic php-mysql question

Very new to php-mysql

I am having trouble using the querystring. In the browser address field I type


In my php script I expect that $id will be defined.
I code

if ($id) { etc

and expect the test to be true if id exists.

Regardless of whether I issue

It is not true

I'm sure there is something I havent learned yet - can someone give me a pointer?

Mysql 5.1.47
Apache 2.2.15

Long ago (maybe 15 years) I did a little active web work .

At that time I used the cgi interface and a C program.

As I recall, I parsed an environmental variable to extract information like form results and the query string. My impression is that this is done for me in php-mysql.

Maybe I'm confused?

Maybe I need to use some function to obtain this data?


rsciw 07-12-2010 10:24 AM

$id doesn't exist.

if you pass variables through the URL, you get it like this:

$id = $_GET['id'];

if ($id)

Make >>sure<< to sanitize >>any<< input you get through the URL, e.g.

$id = striptags(strip_slashes($_GET['id']));

to remove slashes and html/php tags etc. (google for SQL injection, XSS etc.)

also, you may want to check if the $id is numeric, done through

if (is_numeric($id))

rmknox 07-12-2010 10:35 AM

Thank you so much

What an incredibley good resource.

All times are GMT -5. The time now is 05:21 PM.