PHP Fatal error

Discussion in 'Installation/Configuration' started by Pashy, Jun 9, 2010.

  1. Pashy

    Pashy New Member

    Hi friends,
    I am a newbie.
    I am trying to connect PHP with Mysql, but
    coming across the below error:
    PHP Fatal error: Call to undefined function mysql_connect() in /var/www/html/index.php on line 2

    Can anyone suggest with the possbile solution, with easily
    undestandable explanation...

    Thanks in advance..
  2. Mark_NL

    Mark_NL New Member

    Your php installation doesn't have mysql support.

    What linux distribution are you using? debian/fedora/centos?
  3. Pashy

    Pashy New Member

    I am using Fedora 11.
    Mysql version - 5.1.46
    PHP version - 5.2.13
    Apache version - 2.2.15.
  4. Mark_NL

    Mark_NL New Member

    yum install php-mysql
    restart apache and you're good to go
  5. Pashy

    Pashy New Member

    Dear Mark,

    Thanks for your advice, but if your are pointing towards the installation
    of the Drivers I had already done that during PHP installation, using the same
    command that you have mentioned in your reply.

    I am able to display the hello world & PHP info web page with their respective scripts.

    I doubt I have to some changes in the PHP.ini file or httpd.conf file but nor sure what exactly I need to do.
    I have also uncommented all the MySql lines in the PHP.ini file.

    Kindly advice.
  6. Mark_NL

    Mark_NL New Member

    I would not change anything to the php.ini file, unless you know what you're doing.
    The default settings are just fine to start learning php.

    About your error

    unknown function mysql_connect(); means that your php does not have mysql support .. installing the php-mysql package and then restart apache will resolve that issue.

    try this:

    create a file phpinfo.php and put this in it:
    <?php phpinfo(); ?>
    then open that file in your browser, you can see exactly what php supports at that moment. There should be a header called "Mysql"
  7. Pashy

    Pashy New Member

    Thank you Mark,

    Below is the info under header called "Mysql"

    MySQL Support enabled
    Active Persistent Links 0
    Active Links 0
    Client API version 5.1.46
    MYSQL_MODULE_TYPE external
    MYSQL_SOCKET /var/lib/mysql/mysql.sock
    MYSQL_INCLUDE -I/usr/include/mysql
    MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient

    Directive Local Value Master Value
    mysql.allow_persistent On On
    mysql.connect_timeout 60 60
    mysql.default_host no value no value
    mysql.default_password no value no value
    mysql.default_port no value no value
    mysql.default_socket no value no value
    mysql.default_user no value no value
    mysql.max_links Unlimited Unlimited
    mysql.max_persistent Unlimited Unlimited
    mysql.trace_mode Off Off

    Can we say the connection is successful?
  8. Mark_NL

    Mark_NL New Member

    Ok you have mysql support in php.. so if you have a file with something like:
    ini_set('display_erorrs', 1);
    $foo = mysql_connect('localhost', 'user', 'pass');
    You get an error?
  9. Pashy

    Pashy New Member

    Dear Mark,
    Thank you for all your time & kind support.
    The info inserted in the PHP Webpage is reflected
    in the DB table.

    Thanks once again.

    May be I would bother you again since this is just the beginning for me.

  10. Mark_NL

    Mark_NL New Member

    uh oowww ;)

    np mate

Share This Page