• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Call to undefined function: mysql_connect()

I have 2 scripts (PHP Version 4.1.2):

test.php
----------
<?php
  echo exec("php test2.php");

  /*
  ....... some other code
  */
?>


test2.php
------------
<?php
  $link = mysql_connect("www.myserver.com", "user", "pass") or die("Error!!");
  mysql_select_db("MyDb", $link);

  /*
  ....... some other code
  */
?>

test.php should execute the script test2.php. test2.php connects to the database and does some stuff.

The output of test.php is
Fatal error: Call to undefined function: mysql_connect()

But when I execute test2.php directly from the browser this error does not occur. Also when I execute it from the commandline like this: php test2.php, it generates no errormessages.

So I know the problem must be in the exec part.

Any solutions?
0
st0mpie
Asked:
st0mpie
1 Solution
 
Duane LawrenceCommented:
The line

echo exec("php test2.php");

Should be

echo exec("test2.php");

It is different from what you run at the command line.

Duane
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now