The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Remote file include in PHP
Volland
post Dec 3 2008, 01:22 PM
Post #1





Group: Members
Posts: 3
Joined: 3-December 08
Member No.: 7,244



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);
}

?>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 3 2008, 01:34 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 3 2008, 01:35 PM
Post #3


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



** Sorry -- duplicate post **

This post has been edited by Brian Chandler: Dec 3 2008, 01:36 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Volland
post Dec 3 2008, 05:17 PM
Post #4





Group: Members
Posts: 3
Joined: 3-December 08
Member No.: 7,244



If i echo some output in the include file. It would show up.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Volland
post Dec 3 2008, 05:18 PM
Post #5





Group: Members
Posts: 3
Joined: 3-December 08
Member No.: 7,244



but the function doesn't initialize as I understand
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 3 2008, 09:26 PM
Post #6


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 03:36 PM