If I have a class with several functions, and one of the functions is used by the other functions in the class, how do I get to it? In particular I'd like the dbConnect, fail and success functions to be seen by the other functions in the class. I guess I just don't understand the way to use OO yet.
Also, any comments on improving the logic to make sure I don't get duplicate entries would be much appreciated (I'm auto_incrementing a field named 'id' upon insert). here's the code: <?php class alumnus { //error handling function function fail($errorMsg) { $errorMsg = urlencode($errorMsg); print "&result=Fail&errorMsg=" . $errorMsg; exit; } //success notification function function success() { print "&result=Okay"; exit; } //database connection function function dbConnect() { $conxn = mysql_connect('localhost','XXXXX','XXXXX') or fail("Could not connect: ".mysql_error()); $dbSelect = mysql_select_db("alumni", $conxn) or fail("Could not select database: ".mysql_error()); } //processing function function addAlum($fname,$lname,$email) { dbConnect(); //check to make sure they're not already registered $chk = "Select id, fname from contact_info where email =\"{$email}\""; $result = mysql_query($chk); //print mysql_errno($conxn); $getArray = mysql_fetch_assoc($result); //print $getArray['id'] . " " . $getArray['fname']; if ($getArray['id'] !== "") { fail("User already registered. If you would like to edit your user info please click on the edit button."); } else { $insertData = "INSERT into contact_info (fname,lname,tel,address,city,state,zipcode,country,email) VALUES ('$fname','$lname','$tel','$address','$city','$state','$zipcode','$country', \"{$email}\")"; $query = mysql_query($insertData); if (!$query) { fail("There has been a problem: " . mysql_error()); } } else { success(); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php