Help - Search - Members - Calendar
Full Version: Remote file include in PHP
HTMLHelp Forums > Programming > Server-side Scripting
Volland
I'm trying to include file from other server. It works but the function in that file would not work.
It gives me this error:

Fatal error: Call to undefined function: db_connect() in /home/desig181/public_html/store/temp3.php on line 13

This is the source code of a included file:

<?

function db_connect() {
global $db_host;
global $db_user;
global $db_pass;
global $db_name;

$id_link=@mysql_connect($db_host, $db_user, $db_pass);
if (!$id_link) {
syslog(LOG_ERR, getenv("HTTP_HOST").": db_connect(): can't connect to the host \"{$db_host}\"");
}

if (!mysql_select_db($db_name, $id_link)) {
//syslog(LOG_ERR, getenv("HTTP_HOST").": db_connect(): can't connect to database \"{$db_name}\" on \"{$db_host}\": ".mysql_error($id_link));
mysql_close($id_link);

}

return($id_link);
}

?>
Brian Chandler
QUOTE
I'm trying to include file from other server. It works


What do you mean by "works"? Is the file being included? How do you know?

QUOTE


but the function in that file would not work.It gives me this error:Fatal error: Call to undefined function: db_connect() in /home/desig181/public_html/store/temp3.php on line 13

This is the source code of a included file:

<?function db_connect() {...



So the file you claim is being included defines a function db_connect(). But you get the error message db_connect() not defined. The simplest conclusion is that the file is _not_ being included.

Can't really help more without more specific details.
Brian Chandler
** Sorry -- duplicate post **
Volland
If i echo some output in the include file. It would show up.
Volland
but the function doesn't initialize as I understand
Brian Chandler
What do you mean by "initialize"? Do you mean that the following code:

CODE

echo "<p>Before mystery()";

function mystery()
{   echo "Hi! I'm Mystery";
}

echo "<p>After mystery() - before call";

mystery();

echo "<p>That was mystery()";


...produces the output:

CODE

<p>Before mystery()
<p>After mystery() - before call

*** ERROR: function mystery() not defined ***



If so, report it as a (major!) bug. If not, go back and look more carefully.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.