Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

php class help

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

php class help

Postby montv3 » Wed May 15, 2013 4:17 am

Hi guys i need some help. I want to learn php and in a process i cant understand or find mistake in this.

if(!isset($_GET["uid"]) or !isset($_GET["token"])){
$GLOBALS["TEMPLATE"]["content"].="text";
include "/templates/template.php";
exit();
}


$user=new user();
$user=User::getById($_GET["uid"]);
$name=$user->username;

if(!$user=User::getById($_GET["uid"])){
$GLOBALS["TEMPLATE"]["content"].="text";
}
else
{
if($user->isActive){
$GLOBALS["TEMPLATE"]["content"].="text";
}
else {
if($user->setActive($_GET["token"])){
$GLOBAL["TEMPLATE"]["content"].="text";
}
else
{
$GLOBAL["TEMPLATE"]["content"].="text";
}
}

}

this code do what is suppose to do, but i am getting:

! ) Notice: Undefined variable: GLOBAL in D:\Program Files\VertrigoServ\www\svetaine\pending.php on line 33


( ! ) Notice: Undefined index: TEMPLATE in D:\Program Files\VertrigoServ\www\svetaine\pending.php on line 33


( ! ) Notice: Undefined index: content in D:\Program Files\VertrigoServ\www\svetaine\pending.php on line 33

i use $GLOBAL["TEMPLATE"]["content"] in other pages too, but there are no errors, only in this one. Why is that and what should i do? thx
montv3
New php-forum User
New php-forum User
 
Posts: 7
Joined: Wed May 15, 2013 3:46 am

Re: php class help

Postby sandeep605085 » Wed May 15, 2013 6:27 am

Hi,

I think you have not set the values for TEMPLATE array and the key CONTENT in pending.php.
check you other page where use are using $GLOBAL["TEMPLATE"]["content"] that how variable are set.
These variables should be initialized out side the functions.

Refer the below link for the use of GLOBAL variables.
http://php.net/manual/en/reserved.variables.globals.php

Thanks,
Sandeep Agrawal
Mindfire Solutions.
User avatar
sandeep605085
New php-forum User
New php-forum User
 
Posts: 44
Joined: Tue Feb 26, 2013 6:00 am
Location: Mindfire Solutions

Re: php class help

Postby johnj » Wed May 15, 2013 7:19 am

it is not $GLOBAL but $GLOBALS.

you are getting undefined index error because your array does not contain these indices.
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: php class help

Postby montv3 » Wed May 15, 2013 9:55 am

thx for ansver. i was so frustrated that i didnt saw the obviuos.
montv3
New php-forum User
New php-forum User
 
Posts: 7
Joined: Wed May 15, 2013 3:46 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.