thunderbox Posted June 30, 2007 Share Posted June 30, 2007 Hello, i have a website, and i am for the first time running it though functions in an external file (functions.php). how i have set up the page i have a header and a footer (both as includes in their respective places) in the header i have included the file 'functions.php'. yet, when i reference the function (e.g. with login or signup) its says Fatal error: Call to undefined function register() in C:\Program Files\xampp\htdocs\stuff\*******\register.php on line 5 this error goes away when i include the file 'functions.php' directly into the document. however whnen i do this i get this error. Fatal error: Cannot redeclare signup() (previously declared in C:\Program Files\xampp\htdocs\stuff\********\functions.php:6) in C:\Program Files\xampp\htdocs\stuff\********\functions.php on line 31 i am not sure how i can fix the problem, and it is causing to be a major setback int he design and development of the website as i cant get it fixed. any help is appreciated! Quote Link to comment Share on other sites More sharing options...
metrostars Posted June 30, 2007 Share Posted June 30, 2007 Does it work if you copy the code directly in the page where the function is being called from? Quote Link to comment Share on other sites More sharing options...
king arthur Posted June 30, 2007 Share Posted June 30, 2007 Where are the included files? Are they in a different directory? You can work around the problem by using require_once() instead of include() but you should try and figure out why the functions aren't defined and fix that properly. Quote Link to comment Share on other sites More sharing options...
thunderbox Posted June 30, 2007 Author Share Posted June 30, 2007 Does it work if you copy the code directly in the page where the function is being called from? yes it works if the code is directly in the page. Where are the included files? Are they in a different directory? You can work around the problem by using require_once() instead of include() but you should try and figure out why the functions aren't defined and fix that properly. the files area ll in the same directory. where would i put the require_once() would it be directing towards the header.php file or toward the function.php file? Quote Link to comment Share on other sites More sharing options...
Hypnos Posted June 30, 2007 Share Posted June 30, 2007 Sounds like you included something twice, or you have a this "signup" function in two places. Definately try using require_once() or include_once() like king arthur suggested. Use those in place of all of your include()s and require()s Quote Link to comment Share on other sites More sharing options...
thunderbox Posted June 30, 2007 Author Share Posted June 30, 2007 i jsut tried using include_once() and it now comes up witht he other error "Fatal error: Call to undefined function register() in C:\Program Files\xampp\htdocs\stuff\******\register.php on line 7" Quote Link to comment Share on other sites More sharing options...
Hypnos Posted June 30, 2007 Share Posted June 30, 2007 Well, it's your code. You have to figure out where the function is, and why it's not being included. Quote Link to comment Share on other sites More sharing options...
thunderbox Posted June 30, 2007 Author Share Posted June 30, 2007 im using Zend Studio and it says that my functions are void. im not sure why as they all follow this format function name() { } so i have no idea what is going on. this happened with all of my functions so far (i was using a function to do a database connect as well. but when that didn't work i decided to change it to an include and now it works) btw. this is my first real go at using function as i thought it would reduce error checking time as it is all on the one file. but obviously i was wrong. lol 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.