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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.