Undefined index

I get this error when I open the page where you can choose a city to post an ad. Error seems to be in the second line of the code:
$targetview = $_GET['targetview'];
$citylink_view = "view=$targetview&postevent=$_GET[postevent]";
//$citylink_view = "view=selectcity&targetview=$targetview";
 
if($location_sort) 
{
	$sort1 = "ORDER BY countryname";
	$sort2 = "ORDER BY cityname";
}
else
{
	$sort1 = "ORDER BY c.pos";
	$sort2 = "ORDER BY ct.pos";
}

Open in new window

jimgordonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ashish PatelConnect With a Mentor Commented:
But your code which you changed is the right way of doing things.
0
 
jimgordonAuthor Commented:
I changed into:

$postevent = isset($_GET['postevent']);
$targetview = $_GET['targetview'];
$citylink_view = "view=$targetview&postevent=$postevent";

and it works now. It is correct?
0
 
Ashish PatelCommented:
Yes
 in you previous statement you forgot the single quote around the postevent

$citylink_view = "view=$targetview&postevent=$_GET['postevent']";
0
All Courses

From novice to tech pro — start learning today.