I have a JavaScript function making a call to a PHP script. So far so good. A problem happens when I try to do this:
$hike_id = mysql_real_escape_string($_GET['hike_id']);
When I import my connection file, it gives me an error that the functions in that file have already been defined and the error is this:
[Fri Jun 10 12:34:43 2011] [error] [client 75.24.105.18] PHP Fatal error: Cannot redeclare hassuspicioushackerstrings() (previously declared in /home/webadmin/comehike.com/html/connect.php:16) in /home/webadmin/comehike.com/html/connect.php on line 40
The error it is referring to is a function that is in the connect script.
But if I remove the
include '../connect.php';
Then it will just tell me that I can not use the mysql_real_escape_string function. So I am kind of stuck between not being able to use either option.
try include_once '../connect.php';
it'll make sure you're only including once this file
Take a look at your files and your includes... You are declaring that function twice, that is the error. It has nothing to do with MySQL, database connections, or mysql_real_escape_string().
I.e. You may be including file A and file B, but file A already includes file B... You can either figure out where your includes are going wrong, or use include_once
or require_once
to prevent it from double-loading.
Likely you are including the file multiple times. Use require_once instead of include.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With