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

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

 



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;
       $insert = "INSERT INTO $table VALUES('',".$values.") $where";
       $result = mysql_query($insert);
       if ($result) {
           # redirect here
           print $redirect;
       } else {
           print die(mysql_error());
       }
   }
function redirect($url) { $redirect = "<META HTTP-EQUIV=\"refresh\" content=\"0; URL=".WEB_ROOT."$url\">";
       return $redirect;
   }
}
?>

<table>
   <tr>
       <td>
       <?php
$add_location = new DATA; // creates new object named DATA without ("constructor arguments")
       $add_location->redirect('site/index.php');
       $add_location->insert_data('locations',"'Vredendal','02721'",'');
       ?>
       </td>
   </tr>
</table>

--
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