Jump to content

call a class and function in another function


gabs
 Share

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

                }

}

  }

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

                }

}

}

 

 

}

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.