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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



chris smith wrote:

On 4/19/06, Adele Botes <adele@xxxxxxxxx> 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
--

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux