The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't Get Mysql Or Mysqli To Work

Discussion in 'Database Discussions' started by Aram Herschensohn, Apr 21, 2017.

  1. Aram Herschensohn

    Aram Herschensohn Registered

    Joined:
    Apr 21, 2017
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Orange, CA
    cPanel Access Level:
    Website Owner
    Please forgive me if I provide too much information, I do not want to waste anyone's time with missing details. I recently upgraded from Linux Classic Hosting to CPanel and I am having trouble getting connected to the database. The original website is at - Removed - and works flawlessly, using PHP 5.2 (it's still up since I still have the old server up for now). I copied all the files over from the old server using FileZilla and created a new database that has the same username and password, changing the host name to localhost in Connections.php.

    I have confirmed by selecting "PHP version" under the software section that I'm using PHP 5.6 and both mysql and mysqli are enabled. However I get the error: "Fatal error: Call to undefined function mysql_pconnect() in /home/someusr/public_html/Connections/terry.php on line 9" and I get an almost identical error with mysqli. I have provided a screenshot of the PHP commands from cPanel and the code below. Please help me fix this. Thanks.

    I would prefer not to have to upgrade to mysqli as I am simply keeping the original site up until the new godaddy site is ready.

    - Removed -

    Here's the code from the original site (I've changed the names to database and password for security:

    In Connections.php

    Code:
    ?php
    
    # FileName="Connection_php_mysql.htm"
    
    # Type="MYSQL"
    
    # HTTP="true" someusr
    
    $hostname_terry = "*********.secureserver.net";
    
    $database_terry = "database";
    
    $username_terry = "database";
    
    $password_terry = "password";
    
    $terry = mysql_pconnect($hostname_terry, $username_terry, $password_terry) or trigger_error(mysql_error(),E_USER_ERROR);
    
    ?>
    And in Documents.php:

    Code:
    <?php session_start(); ?>
    
    <?php require_once('Connections/terry.php'); ?>
    
    <?php
    
    if (!function_exists("GetSQLValueString")) {
    
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    
    {
    
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    
    
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    
    
      switch ($theType) {
    
        case "text":
    
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    
          break;   
    
        case "long":
    
        case "int":
    
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    
          break;
    
        case "double":
    
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
    
          break;
    
        case "date":
    
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    
          break;
    
       case "defined":
    
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    
          break;
    
      }
    
      return $theValue;
    
    }
    
    }
    
    
    mysql_select_db($database_terry, $terry);
    
    $query_rsCategories = "SELECT * FROM documentcategories ORDER BY categoryOrder ASC";
    
    $rsCategories = mysql_query($query_rsCategories, $terry) or die(mysql_error());
    
    $row_rsCategories = mysql_fetch_assoc($rsCategories);
    
    $totalRows_rsCategories = mysql_num_rows($rsCategories);
    
    
    mysql_select_db($database_terry, $terry);
    
    $query_rsDocuments = "SELECT * FROM documents ORDER BY documentOrder ASC";
    
    $rsDocuments = mysql_query($query_rsDocuments, $terry) or die(mysql_error());
    
    $row_rsDocuments = mysql_fetch_assoc($rsDocuments);
    
    $totalRows_rsDocuments = mysql_num_rows($rsDocuments);
    
    ?>
    
     
    #1 Aram Herschensohn, Apr 21, 2017
    Last edited by a moderator: Apr 22, 2017
  2. Aram Herschensohn

    Aram Herschensohn Registered

    Joined:
    Apr 21, 2017
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Orange, CA
    cPanel Access Level:
    Website Owner
    More information. I put the following code in a test file:

    Code:
    <?php
    if (function_exists('mysql_connect')) {
        echo "mysql_connect exists.<br />\n";
    } else {
        echo "mysql_connect no bueno.<br />\n";
    }
    ?>
    I got back "mysql_connect no bueno." I also get the same result for mysqli_connect. So obviously these functions are not loading.
     
    #2 Aram Herschensohn, Apr 21, 2017
    Last edited by a moderator: Apr 22, 2017
  3. Aram Herschensohn

    Aram Herschensohn Registered

    Joined:
    Apr 21, 2017
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Orange, CA
    cPanel Access Level:
    Website Owner
    Godaddy fixed this! Thanks.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    37,064
    Likes Received:
    1,287
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm happy to see your hosting provider was able to help address the issue. Thank you for updating us with the outcome.
     
Loading...

Share This Page