Jump to content

call a class and function in another function


gabs

Recommended Posts

Hi I have a table class and functions I want to call in another function but can't get it working. Some help will be very welcome.

 

It seesm that the new table class is not working in this function if I pass the values to it, I have tested the class, it does get the post values I post to it so $_POST['id'] are being received as well as all the other $_POST's but the table class and find function is not working, it works fine if I don't put it in a function..

 

function edit() {

   

if (isset($error)){ $error.="Please fix the error(s) above";}

else {

 

if ($_POST['id'] <> "") { 

                   

$update =& new table($db, 'publisher');

 

$update->find($_POST['id']);

$update->name      = $_POST['name'];

$update->url     = $_POST['url'];

$update->contact    = $_POST['contact'];

$update->address    = $_POST['address'];

$update->phone     = $_POST['phone'];

$update->email     = $_POST['email'];

$update->save();

 

$error = "The Publisher has been edited";   

                }

}

  }

if (isset($error)){

Where is $error coming from? If you're about to say "outside the function" then let me reply preemptively with a "functions can't access variables defined outside of them" and how one solution is to have the function return the message.

no error showing, but wound the answer..

 

class sitefunctions extends table {

 

function edit_publisher($db) {

   

 

if (isset($error)){ $error.="Please fix the error(s) above";}

else {

 

if ($_POST['id'] <> "") { 

                   

$update =& new table($db, 'publisher');

 

$update->find($_POST['id']);

$update->name      = $_POST['name'];

$update->url     = $_POST['url'];

$update->contact    = $_POST['contact'];

$update->address    = $_POST['address'];

$update->phone     = $_POST['phone'];

$update->email     = $_POST['email'];

$update->save();

 

$error = "The Publisher has been edited";   

                }

}

}

 

 

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.