Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot redeclare saveorder() (previously declared in :10) on line 71

Tags:

php

I am getting this error for re-declaring saveorder() however, I don't think I am?!?

Cannot redeclare saveorder() (previously declared in :10) on line 71

8.function saveOrder()
9.{
10. include 'tables.php';
11. $orderId       = 0;
12. $shippingCost  = 5;

...

68. }
69. echo $orderId;
70. return $orderId;
71. }
like image 616
Tom Avatar asked Mar 25 '10 23:03

Tom


1 Answers

You could be including the file that contains the function more than once:

  include 'file.php';
  include 'file2.php';

file.php:

  include 'file2.php';

Cannot redeclare saveorder() (previously declared in :10) on line 71

Either use include_once or require_once to make sure it doesn't happen (this can cause problems if you try to include it twice in two separate locations (like first in a file, then later inside a function for some reason, the second one will not work if you include the _once part).

like image 86
SeanJA Avatar answered Nov 15 '22 02:11

SeanJA