Remote file include in PHP |
Remote file include in PHP |
Volland |
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); } ?> |
Brian Chandler |
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. |
Brian Chandler |
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 |
Volland |
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.
|
Volland |
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
|
Brian Chandler |
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. |
Lo-Fi Version | Time is now: 23rd April 2024 - 09:52 AM |