Call to undefined function: mysql_connect()

Posted on 2004-11-03
Last Modified: 2013-12-12
I have 2 scripts (PHP Version 4.1.2):

  echo exec("php test2.php");

  ....... some other code

  $link = mysql_connect("", "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?
Question by:st0mpie
    1 Comment
    LVL 6

    Accepted Solution

    The line

    echo exec("php test2.php");

    Should be

    echo exec("test2.php");

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


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now