tags:

views:

27

answers:

2
 $valid-url = "p1=".rawurlencode($_GET['p1'])."&type=".rawurlencode($_GET['type'])."&os=".rawurlencode($_GET['os'])."&price=".rawurlencode($_GET['price'])."&sort=".rawurlencode($_GET['sort'])."&sort_order=".rawurlencode($_GET['sort_order'])."&perpage=".rawurlencode($perpage)."";

i am trying to build the url and pass it to <a href=''..but its throwing escaping problem...can i get some help on this.

+1  A: 

You should try to name the variable properly - is not allowed in variable names in PHP

Reference:

http://www.php.net/manual/en/language.variables.basics.php

Quote:

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'

Patrick Cornelissen
+1  A: 

You can't use '-' in variable names! Your fixed code is:

$validurl = "p1=".rawurlencode($_GET['p1'])."&type=".rawurlencode($_GET['type'])."&os=".rawurlencode($_GET['os'])."&price=".rawurlencode($_GET['price'])."&sort=".rawurlencode($_GET['sort'])."&sort_order=".rawurlencode($_GET['sort_order'])."&perpage=".rawurlencode($perpage)."";
zaf
@pradeep, if this is the answer please mark it so others know next time :) Thanks.
Rob
thanks for tht help..i made a fool of ma php skills :(
pradeep