the apprentice webmaster Posted April 2, 2006 Share Posted April 2, 2006 i am trying to run this script and i get this error message :" Fatal error: Call to undefined function admin_check() in C:\Program Files\xampp\htdocs\bpo\admin\newscategory.php on line 6here the script :" <?phpinclude $_SERVER['DOCUMENT_ROOT']. '/bpo/layout.php'; // Quick Admin session check [b] this is line 6-->[/b] admin_check(); switch($_REQUEST['req']){ // Category Insert Case case "create_cat": myheader("Add News Category"); // Double check form posted values are there // before performing INSERT query if(!$_POST['cat_name'] || !$_POST['cat_description']){ echo '<p align="center">Missing Form Information!</p>'. '<p align="center">Please use your browser back '. 'button and complete the form.</p>'; footer(); exit(); } // Insert Query $sql = mysql_query("INSERT INTO news_categories (cat_name, cat_description) VALUES('{$_POST['cat_name']}', '{$_POST['cat_description']}')"); // Insert query results if(!$sql){ echo "Error with MySQL Query: ".mysql_error(); } else { echo '<p align="center">Category '.$_POST[cat_name]. ' created!<br />New category id: '.mysql_insert_id(); echo '<br /><a href="/bpo/admin/newscategory.php?req=new_cat">Create '. 'another category</a>'; } break; // Create category form case case "new_cat": myheader("Create News Category"); include $_SERVER['DOCUMENT_ROOT']. '/bpo/html/forms/news_category_insert.html'; footer(); break; default: myheader("News Category Administration"); include $_SERVER['DOCUMENT_ROOT']. '/bpo/html/news_cat_admin.html'; footer(); break; }?> so can anyone help me here thx in advance , Quote Link to comment Share on other sites More sharing options...
alpine Posted April 2, 2006 Share Posted April 2, 2006 you are missing the function called "admin_check()", should be decleared above the request for it or in a included script. Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted April 2, 2006 Author Share Posted April 2, 2006 [!--quoteo(post=361012:date=Apr 2 2006, 05:35 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ Apr 2 2006, 05:35 PM) [snapback]361012[/snapback][/div][div class=\'quotemain\'][!--quotec--]you are missing the function called "admin_check()", should be decleared above the request for it or in a included script.[/quote]thx for your reply , the function " admin_check(); is defined here in my session.php :: <?phpsession_start();session_name( 'MyPHPSite' );header( "Cache-conrol : private"); // Fix for IEfunction login_check(){if($_SESSION['login'] != TRUE ){myheader("Login Required!");include $_SERVER['DOCUMENT_ROOT']. '/bpo/html/forms/login_form.html'; footer(); exit(); } } function admin_check(){ if($_SESSION['admin_access']{ myheader("Access Denied!") echo "<center>This Area is Restricted". " For Website Administrators!"; footer(); exit(); } }?> Quote Link to comment Share on other sites More sharing options...
alpine Posted April 2, 2006 Share Posted April 2, 2006 then you must include or rather require session.php in your script, like this - assuming the same path:[code]<?phprequire $_SERVER['DOCUMENT_ROOT'].'/bpo/session.php';include $_SERVER['DOCUMENT_ROOT'].'/bpo/layout.php';// Quick Admin session checkadmin_check();// bla bla, script goes on?>[/code] Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted April 2, 2006 Author Share Posted April 2, 2006 [!--quoteo(post=361015:date=Apr 2 2006, 05:47 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ Apr 2 2006, 05:47 PM) [snapback]361015[/snapback][/div][div class=\'quotemain\'][!--quotec--]then you must include or rather require session.php in your script, like this - assuming the same path:[code]<?phprequire $_SERVER['DOCUMENT_ROOT'].'/bpo/session.php';include $_SERVER['DOCUMENT_ROOT'].'/bpo/layout.php';// Quick Admin session checkadmin_check();// bla bla, script goes on?>[/code][/quote] thx i fix that part , when i run the script now i got this error now : Parse error: syntax error, unexpected T_ECHO in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 18 if(!$_POST['cat_name'] || !$_POST['cat_description']){ echo '<p align="center">Missing Form Information!</p>'. [b] line 18 is ---> [/b]'<p align="center">Please use your browser back button and complete the form.</p>'; i am working on it , but if you can help that will be nice , Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted April 2, 2006 Author Share Posted April 2, 2006 [!--quoteo(post=361019:date=Apr 2 2006, 05:55 PM:name=apprentice webmaster)--][div class=\'quotetop\']QUOTE(apprentice webmaster @ Apr 2 2006, 05:55 PM) [snapback]361019[/snapback][/div][div class=\'quotemain\'][!--quotec--]thx i fix that part , when i run the script now i got this error now : Parse error: syntax error, unexpected T_ECHO in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 18 if(!$_POST['cat_name'] || !$_POST['cat_description']){ echo '<p align="center">Missing Form Information!</p>'. [b] line 18 is ---> [/b]'<p align="center">Please use your browser back button and complete the form.</p>'; i am working on it , but if you can help that will be nice ,[/quote]Any help guys , seems i can found the error , please help thx , i am waitng for some of your reply thx again [b]Error[/b] :Parse error: syntax error, unexpected T_ECHO in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 18 Quote Link to comment Share on other sites More sharing options...
Mr.x Posted April 2, 2006 Share Posted April 2, 2006 Try[code]if(!$_POST['cat_name'] || !$_POST['cat_description']){echo "<p align='center'>Missing Form Information!</p><br><p align='center'>Please use your browser back button and complete the form.</p>";[/code] Quote Link to comment Share on other sites More sharing options...
the apprentice webmaster Posted April 2, 2006 Author Share Posted April 2, 2006 [!--quoteo(post=361029:date=Apr 2 2006, 06:17 PM:name=Seanyboy)--][div class=\'quotetop\']QUOTE(Seanyboy @ Apr 2 2006, 06:17 PM) [snapback]361029[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try[code]if(!$_POST['cat_name'] || !$_POST['cat_description']){echo "<p align='center'>Missing Form Information!</p><br><p align='center'>Please use your browser back button and complete the form.</p>";[/code][/quote][i]thx very much it work now , but look at the error message i get on top of the page , can someone tell me why i am getting it , thx very much , you guys are very helpfull , but look at this error message [/i][u][b]Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\xampp\htdocs\bpo\classes\clsMetaContent.php:45) in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 2Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\xampp\htdocs\bpo\classes\clsMetaContent.php:45) in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 2Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\bpo\classes\clsMetaContent.php:45) in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 4[/b] Quote Link to comment Share on other sites More sharing options...
Mr.x Posted April 2, 2006 Share Posted April 2, 2006 I don't have time to look at the code of the script, but a possible quick fix could be putting on line 1 [code] <? session_start(); ?> [/code]I'm not 100% sure. Quote Link to comment Share on other sites More sharing options...
shortj75 Posted April 3, 2006 Share Posted April 3, 2006 this just means your sessions are already started from one of the pages session.php or layout.php and can not be started again[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\xampp\htdocs\bpo\classes\clsMetaContent.php:45) in C:\Program Files\xampp\htdocs\bpo\includes\session.php on line 2[/quote]place this at the top of your page it will stop your page from showing the warning or notice errors [code]<? error_reporting(E_ERROR);?>[/code][ Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 3, 2006 Share Posted April 3, 2006 if its a warning then apprentice webmaster's script wont run at all!apprentice webmaster the error message is saying you have somethikng being outputted to the browser near/on line 45 in clsMetaContent.phpWhat is around line 45 in clsMetaContent.php. Could you post lines 40 - 50. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.