I'm getting this for my site and it's not loading: PHP Fatal error: Cannot redeclare date_add() in /home/footyall/public_html/include/functions.php on line 1882 Any ideas of how to fix it?
as the error says.. the is already a built-in function named date_add you can redeclare it / replace with yours.. would help if you shared the code but thats exactly as its telling you.. Added info for the function: http://php.net/manual/en/function.date-add.php
Thanks for the reply. I don't really understand anything about php. I've included the code below. What would I have to amend? https://www.dropbox.com/s/ix82x7qrcjn2xck/functions.php?dl=0
Rename this function: function date_add($timestamp, $months) { $d = getdate ($timestamp); $mon = $months % 12; $years = $months / 12; $mytime = mktime ($d['hours'], $d['minutes'], $d['seconds'], $d['mon'] + $mon, 1, $d['year'] + $years); $days = min ($d['mday'], date ('t', $mytime)); $mytime += ($days -1) * 86400; return $mytime; } Code (markup): rename: date_add bit.. Note you will need to find everywhere you are actually using this and also change it.. i.e if you are calling that function elsewhere you need to rename it the same.. thanks
Thanks, so just anything? What I don't get is why the previous one stopped working. Is there a reason why?
yeah.. as i mentioned earlier "Added info for the function: http://php.net/manual/en/function.date-add.php" the is already a built in function called it as above.. thats why Note: feel free to push "best answer" if you found my replies helpful
Let me try and understand...php has an added function now which is conflicting with it. Is that right?
i actually think this function has been around for a while did your server possibly update php versions recently?
Yeah, the site was offline for a while and I re-uploaded it. Any idea how I can search for all instances of the function?
i would use agent ransack (google it.. freeware for none commercial use) search for instances containing that specific function
For future, always use "camelCase" for your own functions. That word "camelCase" is written in camel case. That way your written functions will not conflict with php's builtin functions. Also consider using if(!function_exists("functionName")){ } for every function you write.