Fatal Error in PHP coding
|
10-27-2010, 07:18 PM
Post: #1
|
|||
|
|||
Fatal Error in PHP coding
I am encountering an error with the following section of PHP and cannot see the reason. The error is being trapped with the line
Code: $validator->validateTextOnlyNoSpaces($HTTP_POST_VARS['name'],'section name'); The error message is: Fatal error: Call to a member function validateTextOnlyNoSpaces() on a non-object in C:\Program Files\xampp\htdocs\newsite2\cmsadmin\newSection.ph p on line 33 Now, this implies that the $HTTP_POST_VARS field of 'name' is not in existence and yet I have declared it clearly within the form at the bottom of the code. The submit is set correctly. Anyone see what I am missing? <?php // Call the classes require_once('../includes/DbConnector.php'); require_once('../includes/Validator.php'); // Create instances $connector = new DbConnector(); $theValidator = new Validator(); // DELETE SECTION //////////////////////////////////////////////////////////////////// if ($HTTP_GET_VARS['action'] == 'delete') { // Store the ID of the section to be deleted in a variable $sectionID = $HTTP_GET_VARS['id']; // Validate the section ID, and if it's ok then delete the section if ( $validator->validateNumber($sectionID,'Section ID') ) { // The validator returned true, so go ahead and delete the section $connector->query('DELETE FROM cmssections WHERE ID = '.$sectionID); echo 'Section Deleted <br><br>'; } else { // The validator returned false, meaning there was a problem echo "Couldn't delete. There was a problem with: ".$validator->listErrors(); } } // ADD SECTION //////////////////////////////////////////////////////////////////// if ($HTTP_GET_VARS['action'] == 'add') { $validator->validateTextOnlyNoSpaces($HTTP_POST_VARS['name'],'section name'); $validator->validateNumber($HTTP_POST_VARS['parent'],'parent section'); if (!$validator->foundErrors()) { $connector->query('INSERT INTO cmssections (name,parentid) VALUES ("'.$HTTP_POST_VARS['name'].'",'.$HTTP_POST_VARS['parent'].')'); } else { echo '<b>Please correct '.$validator->listErrors().'</b><br><br>'; } } // LIST SECTIONS ///////////////////////////////////////////////////////////////////// $result = $connector->query('SELECT ID,name,parentid FROM cmssections'); // Get an array containing the results. // Loop for each item in that array while ($row = $connector->fetchArray($result)) { echo $row['name'].' - '; // Show the name of section echo '<a href="newSection.php?action=delete&id='.$row['ID'].'"> Delete </a>'; // Show the delete link echo '<br>'; // Show a carriage return } ?> <form name="form1" method="post" action="newSection.php?action=add"> <p>Create a Section:</p> <p> Name: <input name="name" type="text" id="name"> </p> <p> Parent: <select name="parent"> <option value="0">None</option> <?PHP // Generate a drop-down list of sections. // NOTE : Requires database modifications in article 4 $result = $connector->query('SELECT ID,name FROM cmssections ORDER BY name'); // Get an array containing the results. // Loop for each item in that array while ($row = $connector->fetchArray($result)) { echo '<option value="'.$row['ID'].'">'.$row['name'].'</option>'; } ?> </select> </p> <p align="left"> <input type="submit" name="Submit" value="Create"> </p> </form> Web Design Directory | Web Designers | SEO Melbourne |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Fatal Error in PHP coding - petermoses - 10-27-2010 07:18 PM
RE: Fatal Error in PHP coding - barbaragabogrecan - 12-13-2010, 05:19 PM
RE: Fatal Error in PHP coding - justinOrel - 02-04-2011, 03:59 PM
RE: Fatal Error in PHP coding - anusha - 10-28-2011, 05:08 PM
RE: Fatal Error in PHP coding - jackiecrains - 09-06-2012, 12:08 AM
|
User(s) browsing this thread: 1 Guest(s)