Re: Help using a function within a function, both within a class

From: Date: Wed, 19 Apr 2006 12:07:35 +0000
Subject: Re: Help using a function within a function, both within a class
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-234264@lists.php.net to get a copy of this message
chris smith wrote:
On 4/19/06, Adele Botes <adele@trusc.net> wrote:
To anyone who can help, I would like to know why or how I can execute a function within a function used within this class. I want to redirect if the results of a insert query was successful, so i made a simple redirect function for later use, once I've build onto the class. The problem is that i am not sure why or how to get the redirect($url) to work within insert_data($table,$values,$where) Even if I call the function: print redirect($url); and add the $url argument to insert_data it still doesn't work. I get undefined function error. What am I doing wrong? <?php require_once('../config.inc.php'); // contains define(WEB_ROOT, 'http://www.example.com'); and $db_connection class DATA { // variables var $table; var $fields; var $where; var $url; // Constructor must be the same name as the class // Functions function insert_data($table,$values,$where) {
       global $redirect;
   
You don't use globals inside a class to reference other data inside the same class. Instead you need to do something like this: $add_location->url = 'blah'; then inside the class: if ($result) {
          # redirect here
          print $this->redirect($this->url);
... -- Postgresql & php tutorials http://www.designmagick.com/ Chris
Thanx allot for your help. I works gr8. Adele --

« previous php.general (#234264) next »