Really wierd problem with include and $_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Really wierd problem with include and $_GET

Post by kaisellgren »

Code: Select all

<?php
$siteid = $_GET["siteid"];
if ($siteid = "7")
include("adminmain.php");
?>
That was my code, but when I run the file as "index.php?siteid=4", it will include the adminmain.php file!? Can you notice any bug in my script or custom?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you're setting it to 7...you need to use the comparison operator "=="

ie:

Code: Select all

<?php 
$siteid = $_GET["siteid"]; 
if ($siteid == "7") 
include("adminmain.php"); 
?>
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Post by kaisellgren »

Oh damn! That was very fast reply thanks! I have not been using PHP for long time so I don't even remember the basics :S I have been using programming language that doesn't need the double =. Thank you for fast reply!
Post Reply