Professional Web Applications Themes

Fatal error: Call to undefined function - PHP Development

I'm a PHP and MySQL newbie. I have a feeling a lot of you may have seen this before. I'm teaching myself PHP/MySQL and trying to setup a guestbook. I'm running latest versions of Apache, PHP and MySql on WIN 2000. PHP is installed from the zip file. When serving php docs (code snippets below) I get the messages: "Fatal error: Call to undefined function mysql_connect() " "Fatal error: Call to undefined function mysql_pconnect() " I've been reading and searching and trying all sorts of things to fix this and can't find the solution. I've removed the comment from the ...

  1. #1

    Default Fatal error: Call to undefined function

    I'm a PHP and MySQL newbie. I have a feeling a lot of you may have seen this
    before. I'm teaching myself PHP/MySQL and trying to setup a guestbook. I'm
    running latest versions of Apache, PHP and MySql on WIN 2000. PHP is
    installed from the zip file. When serving php docs (code snippets below) I
    get the messages:

    "Fatal error: Call to undefined function mysql_connect() "

    "Fatal error: Call to undefined function mysql_pconnect() "

    I've been reading and searching and trying all sorts of things to fix this
    and can't find the solution. I've removed the comment from the line
    "extension=php_mysql.dll" in php.ini. (Below is the MySQL section of
    php.ini. It's pretty standard, I'm using defaults.) I edited my Apache
    config file with the needed lines:

    ### Section 4: PHP 5 Module

    #

    ScriptAlias /cgi-bin/ "C:/Program Files/Apache

    Group/Apache2/cgi-bin/"

    LoadModule php5_module php/php5apache2.dll

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php-source .phps

    PHPIniDir "C:/Program Files/Apache Group/Apache2/PHP"

    When I run phpinfo, MySQL is not listed. Do I need to enable it in the
    configure command? How do I edit the configure command. Per phpinfo, It now

    reads:

    Configure Command cscript /nologo configure.js "--with-gd=shared"
    "--enable-snapshot-build"

    I read these comments:

    Ok, your php.ini file is set to 'on' for mysql.allow_persistent, but is
    mysql really enabled? Does your configure command look something like this?

    './configure'
    '--with-mysql=/usr/local/mysql'............................................

    If you don't have --with-mysql it means that you cannot use mysql
    functions, so compile PHP again with this option.



    How do I edit that pesky configure command. I searched, but couldn't find an
    answer. So, where am I going wrong? Thanks for reading and big thanks for
    any help.

    gene

    [email]sunishunverizon.net[/email]



    php.ini snippet (comments removed for easier reading:

    [MySQL]

    mysql.allow_persistent = On

    mysql.max_persistent = -1

    mysql.max_links = -1

    mysql.default_port =

    mysql.default_socket =

    mysql.default_host =

    mysql.default_user =

    mysql.default_password =

    mysql.connect_timeout = 60

    mysql.trace_mode = Off



    guest.php code snippet:

    //connect

    // change localhost to your db host name

    mysql_pconnect( "http://aulon.dyndns.org/", "$username", "$password")

    or die( "Unable to connect to SQL server");

    mysql_select_db( "$db_name") or die( "Unable to select database");

    guestbook.php code snippet:

    // Connect to DB

    $li = mysql_connect($dbHost, $dbUser, $dbPass) or die("Could not connect");

    mysql_select_db($dbDatabase, $li) or die ("could not select DB");






    gc Guest

  2. #2

    Default Re: Fatal error: Call to undefined function

    gc wrote:
    > How do I edit that pesky configure command. I searched, but couldn't
    > find an answer. So, where am I going wrong? Thanks for reading and
    > big thanks for any help.
    >
    You don't under Windows. During restart of Apache I imagin that you get an
    error message related to the php_mysql.dll.

    When this is the case, be sure to copy the libmysql.dll (also in de zip
    distribution) to the %windir%\system32 directory and to restart Apache after
    you have copied the file.


    JW



    Janwillem Borleffs Guest

  3. #3

    Default Re: Fatal error: Call to undefined function

    Someone suggested I revert to PHP4. I did and it works finally! Here's the
    message.

    __________________________________________________ __-

    Latest MySQL and PHP5 don't mix by default on Windows. You need another
    Mysqllib. There are some functions that no longer exist in PHP I believe. I
    found it a nightmare to get it to work, but others can probably point out
    how exactly to do this. I gave up after hours of toying, went back to PHP
    4.3.8 so I can't exactly tell you how to go about it.

    Good luck Pjotr

    __________________________________________________ __-

    Thanks for helping.

    gene


    gc Guest

  4. #4

    Default Re: Fatal error: Call to undefined function

    gc wrote:
    > Someone suggested I revert to PHP4. I did and it works finally! Here's the
    > message.
    Well in fact you only needed to put the libmysql.dll (that is given in
    the PHP5 zip file) in your environment PATH. (e.g.: put it in your
    windows dir, although this is not recommended.) and uncomment the
    correct line in your php.ini. But i suppose that if you switched back to
    good old 4.3.x you didn't really need 5.x

    Best regards,
    Sebastian



    --
    The most likely way for the world to be destroyed,
    most experts agree, is by accident.
    That's where we come in; we're computer professionals.
    We cause accidents.
    --Nathaniel Borenstein
    Sebastian Lauwers Guest

Similar Threads

  1. Fatal error: Call to undefined function: mime_content_type()
    By Randell D. in forum PHP Development
    Replies: 1
    Last Post: September 16th, 08:32 PM
  2. Replies: 5
    Last Post: September 13th, 06:28 PM
  3. Replies: 5
    Last Post: September 13th, 06:27 PM
  4. Fatal error: Call to undefined function: mysql_connect()
    By Naintara Jain in forum PHP Development
    Replies: 1
    Last Post: September 12th, 02:41 PM
  5. #24747 [Bgs]: Fatal error: Call to undefined function: stripos()
    By tagg_maiwald at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: July 22nd, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139