Page 1 of 1

Sticking variables in a MySQL Query?

Posted: Sun Nov 24, 2002 6:36 pm
by Jim
I'm using this code to authenticate permission in editing a certain news portion of the site.

Code: Select all

$sql = "select id from EGN_User_Sites where user_name = '$EGNewsUser' and '{$name}' = '1'";
That $name comes from a query string like this:

Code: Select all

http://mysite.com/newsprogram/editnews.php?action=add&name=butt
Any idea on what to replace '{$name}' with?

Posted: Mon Nov 25, 2002 2:27 am
by volka
maybe {$_GET['name']} ?

Posted: Mon Nov 25, 2002 5:07 pm
by mydimension
what about this:

Code: Select all

$sql = "select id from EGN_User_Sites where user_name = '$EGNewsUser' and name = $name";

Posted: Mon Nov 25, 2002 11:34 pm
by BigE
No, volka is right here, he needs to use $_GET['name'] in this case. However, that is assuming you are running PHP 4.1.x or higher and register_globals is off.