Jump to content

Functions Problems


thunderbox

Recommended Posts

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!

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

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