Jump to content

Problem with MSSQL connection


mervyn3399

Recommended Posts

Fatal error: Call to undefined function mssql_connect() in C:\AppServ\www\library\inc\SQL.php on line 23

 

This is for my personal website. I will post my full script for that issue there

 

The error was shown where I coloured the code in red. Thanks to anyone who is able to help me with this problem

 

 

<?php

/*

LastThief's Ultimate Sro Class

Email:lastthiefrocketmail.com

Please do not remove this.

*/

include("checkit.php");

class SQL

{

    protected $connection;

    protected $connectionInfo;

   

    public function SQL($credentials, $connect)

    {

        $this->connectionInfo = $credentials;

       

        if ($connect)

            $this->Connect();

    }

   

    public function Connect()

    {

      $this->connection = mssql_connect($this->connectionInfo['Host'], $this->connectionInfo['User'], $this->connectionInfo['Pass']);

       

        if (!$this->connection)

            die('Couldn\'t establish a connection to the datatabase');

    }

   

    public function getConnection()

    {

        return $this->connection;

    }

   

    public function Query($query)

    {

        $result = mssql_query($query, $this->connection);

       

        if (!$result)

            die('Couldn\'t execute query.');

       

        return $result;

    }

   

    public function selectDB($db)

    {

        if (!mssql_select_db($db, $this->connection))

            die('Couldn\'t select database.');

    }

   

    public function Close()

    {

        mssql_close($this->connection);

    }

   

    public function rowcount($result)

    {

        $return = mssql_num_rows($result);

       

        if (!$result)

            die('Could\'t get rowcount.');

       

        return $return;

    }

   

    public function fetchrow($resource)

    {

        $result = mssql_fetch_row($resource);

        return $result;

    }

   

    public function fetcharray($resource)

    {

        $result = mssql_fetch_array($resource);

        return $result;

    }

   

    public function fetchassoc($resource)

    {

        $result = mssql_fetch_assoc($resource);

        return $result;

    }

   

    public function rowsaffected()

    {

        $rows = mssql_rows_affected($this->connection);

        return $rows;

    }

    function is_secure($string)

    {

        $pattern = "#[^a-zA-Z0-9_\-]#";

        if (preg_match($pattern, $string) == true)

            return false;

        else

            return true;

    }

    function MessageBox($message, $delay, $url)

    {

        echo "<script>

        alert(\"$message\")

            </script>";

       

        header("Refresh: $delay; url=$url");

       

    }

    function redirect($url, $permanent = false)

    {

        if ($permanent) {

            header('HTTP/1.1 301 Moved Permanently');

        }

        header('Location: ' . $url);

        exit();

    }

    public function Result($query, $number, $rowname)

    {

        $result = mssql_result($query, $number, $rowname);

        return $result;

    }

 

    function check_access($file)

    {

        if (eregi("$file", $_SERVER['PHP_SELF'])) {

            die("<h4>You don't have right permission to access this file directly.</h4>");

        }

    }

    function count_to_date($sqldate, $day, $month, $year)

    {

        $d  = substr($sqldate, 8, 2);

        $m  = substr($sqldate, 5, 2);

        $y  = substr($sqldate, 0, 4);

        $h  = substr($sqldate, 11, 2);

        $min = substr($sqldate, 14, 2);

       

        $d = intval($d) + $day;

        $m = intval($m) + $month;

        $y = intval($y) + $year;

        if ($d > 31) {

            while ($d > 31) {

                $d -= 31;

                $m += 1;

            }

        }

        if ($m > 12) {

            while ($m > 12) {

                $m -= 12;

                $y += 1;

            }

        }

        //below sets sequence: day/month/year

        if ($d < 10)

            $d = '0' . $d;

        if ($m < 10)

            $m = '0' . $m;

        $r = $y . '-' . $m . '-' . $d . ' ' . $h . ':' . $min . ':00.000';

        return $r;

       

    }

   

    function ms_escape_string($data)

    {

        if (!isset($data) or empty($data))

            return '';

        if (is_numeric($data))

            return $data;

       

        $non_displayables = array(

            '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15

            '/%1[0-9a-f]/', // url encoded 16-31

            '/[\x00-\x08]/', // 00-08

            '/\x0b/', // 11

            '/\x0c/', // 12

            '/[\x0e-\x1f]/' // 14-31

        );

        foreach ($non_displayables as $regex)

            $data = preg_replace($regex, '', $data);

        $data = str_replace("'", "''", $data);

        return $data;

    }

function isValidEmail($email){

return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);

    }

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/261532-problem-with-mssql-connection/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.