Results 1 to 6 of 6

Thread: Can't connect PHP to MySQL in Kubuntu

  1. #1
    Join Date
    Sep 2007
    Location
    Leominster, Massachusetts
    Beans
    61
    Distro
    Kubuntu 10.04 Lucid Lynx

    Can't connect PHP to MySQL in Kubuntu

    I'm trying to run php scripts on Kubuntu 10.04 that connect to a MySQL database. These scripts run perfectly on OS X 10.6.6, but when I run them in Kubuntu, I get the following error:

    The script...
    <?php
    $mysql = mysql_connect('127.0.0.1', 'peterv', 'password');
    if (mysql_connect_errno()) {
    printf("Connect failed: %s\n", mysql_connect_errno());
    exit();
    } else {
    printf("Host information: %s\n", mysql_get_host_information($mysql));
    }
    ?>

    The error message:
    "Fatal error: Call to undefined function mysql_connect() in..."

    I've seen some posts in other boards about Red Hat problems like this, but nothing that can help with Kubuntu. I'd really appreciate a hand with this.
    Thanks,
    Peter V.

  2. #2
    Join Date
    Jun 2010
    Location
    Highlands, Scotland
    Beans
    153
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Can't connect PHP to MySQL in Kubuntu

    i have made a few edits and it works on my system
    Code:
    <?php
    	$mysql = MySQL_Connect('localhost', 'root', 'password');
    		if(!$mysql) {
    			printf("Connect failed: %s\n", mysql_error());
    			exit();
    		} else {
    			printf("Host information: %s\n", mysql_get_host_info($mysql));
    		}
    ?>
    hope it helps some

  3. #3
    Join Date
    Sep 2007
    Location
    Leominster, Massachusetts
    Beans
    61
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Can't connect PHP to MySQL in Kubuntu

    wiggly, thanks for the attempt, but it still doesn't work. Since it's giving me an error for an undefined function call, I think it has something to do with my php installation.

  4. #4
    Join Date
    Jun 2010
    Location
    Highlands, Scotland
    Beans
    153
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Can't connect PHP to MySQL in Kubuntu

    can you post the whole error?

  5. #5
    Join Date
    Sep 2007
    Location
    Leominster, Massachusetts
    Beans
    61
    Distro
    Kubuntu 10.04 Lucid Lynx

    Re: Can't connect PHP to MySQL in Kubuntu

    Sure:

    Code:
    Fatal error: Call to undefined function mysql_connect() in /var/www/LP2/dbc.php on line 2.
    Thanks for looking!

  6. #6
    Join Date
    Mar 2012
    Beans
    17

    Re: Can't connect PHP to MySQL in Kubuntu

    you installed php and mysql separately. you should install php-mysql

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
  •