I have tried in many servers the following type of calling a connection and never have any mistakes but I have tried the same at a friends server and it gives me this error:
Fatal error: Cannot redeclare connect() in /var/www/html/portal/conexion.php on line 3
the code for conexion.php is the following:
//------------------------------------
//THIS IS conexion.php
<?
function connect()
{
@$db=mysql_connect("localhost", "login", "password");
if(!$db)
{
echo"Can not connect to databse";
echo"Please try again";
exit;
}
mysql_select_db("mydatabase");
}
?>
and the way I call this connection script is the following:
for example my index.php
//------------------------------------
//THIS IS index.php
<?
include("conexion.php");
connect();
$res=mysql_query("select * from table_1");
while($re=mysql_fetch_array($res))
{
echo$re[field1]."<br>";
}
?>