Skip to main content
gamedev.net
🔒 Locked 🤖 Godot

[web] PHP Problem. HELP!!

Started by EXER May 22, 2009 at 2:22 AM 4 replies 1.3k views
Original Post
EXER
EXER
I know this is a very basic PHP script but it does not work. I am using a "page" variable and using the $_GET function to get the "page" vaiable. Here is the script: As i said, it is very basic but does not work. The script does not get the "page" variable from the address, i have even looked at using the echo function to show me the "page" variable but does not return anything. Is this a problem with my script or with my server.
ToohrVyk
ToohrVyk
$_GET is not a function. It's a variable. Your code should look like this:

$page = $_GET['page'];if ($page === 'something') {...}
smitty1276
smitty1276
You didn't give us much information... like, what url did you use to access the page, etc. And where are you storing the variable page?
EXER
EXER
Thanks, i have updated my page an it works fine. I think the tutorial im reading is 99% wrong.
Sonnenblume
Sonnenblume
Also remember to sanitize $_GET["page"], you should NEVER trust any value being provided via a URL, i.e. by using functions such as strip_tags(), stripslashes() or mysql_real_escape_string() if your going to be using it in a database.

i.e. $page = mysql_real_escape_string($_GET["page"]);
ToohrVyk
ToohrVyk
Quote:
Original post by Sonnenblume
or mysql_real_escape_string() if your going to be using it in a database.


I would advise against the use of mysql_real_escape_string: it's too easy to forget about escaping a value with that function.

I personally only every use mysqli and the prepared statement interface, which auto-escapes all values you provide so that you cannot forget about escaping them.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.