mysql - Weird PHP "Fatal error: Cannot redeclare" Error -



mysql - Weird PHP "Fatal error: Cannot redeclare" Error -

my script returning next error...

fatal error: cannot redeclare connecttodatabase() (previously declared in /var/www/api/connecttodatabase.php:4) in /var/www/api/connecttodatabase.php on line 6

and next connecttodatabase.php file...

<?php function connecttodatabase() { $con = @mysqli_connect("localhost", "name", "password", "database"); homecoming $con; } ?>

i don't understand error because line 6 closed curly bracket (})

i think error means thinks declared function connecttodatabase() in different spots didn't.

as others have said in comments, because have included connecttodatabase.php twice in code, , defining function twice. don't hung why it's line 6; line 2 more helpful, line 6 function definition ends, , arguably is when function defined. have "one day" whole year calendar on idiosyncrasies of php , have plenty left on sequel. others have hinted, basic debugging confirm whether including file more 1 time , where.

make sure code uses include_once or require_once.

php mysql function

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -