Find the answer to your Linux question:
Results 1 to 9 of 9
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 ...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    10

    PHP Fatal error

    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..
    pashy

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Could you post the contents of index.php file here?
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Posts
    4
    Most likely mysql is not enabled on your php installation. Create a dummy HTML page on your web server with the php code from below and call it through the web browser. It will tell you if mysql is enabled.

  4. #4
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    Do you have the php-mysql package installed? You need that.

  5. #5
    Just Joined!
    Join Date
    Apr 2010
    Posts
    10
    Hi Folks,

    Thanks for all your replies.
    I have fixed the problem & the connection is sucessful.
    Just sharing this exp in case any one faces the problem in future.
    The php-mysql package was missing.

    After installing it & uncommenting some mysql lines in the php.ini file.

    I was able to echo the function in the php web page but had a new error in the error logs file:
    connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

    as you guys can see number 13 in the error
    #perror 13
    OS error code 13: Permission denied
    It was an OS error about permissions.

    Eventually after :
    #chmod 777 /var/lib/mysql

    Everything worked fine, atleast as of now..

    Cheer's

  6. #6
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    755 would be better than 777
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  7. #7
    Just Joined!
    Join Date
    Apr 2010
    Posts
    10
    Sorry what do you mean by "PM"?

  8. #8
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    PM - Private Message

    You don't really want your /var/lib/mysql directory to be world writeable!
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  9. #9
    Just Joined!
    Join Date
    Apr 2010
    Posts
    10
    ohh..! I see, thanks.

Posting Permissions

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