+ Reply to Thread
Results 1 to 3 of 3

Thread: PGSQL and Errors ._.

  1. #1
    Shadow121's Avatar
    Shadow121 is offline x10 Lieutenant Shadow121 is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Centerville
    Posts
    455

    PGSQL and Errors ._.

    I'm trying to make a database class and its being odd and not giving me an error when I try to use PGSQL yet it does with MySQLi and MySQL. Can someone help? e.e

    PHP Code:
    class database
    {
        
    /**
         * The different databases supported
         * @access private
         */
        
    private $dbTypes = array("MySQL""MySQLi""PGSQL");

        
    /**
         * Current link
         * @access private
         */
        
    private $link;

        
    /**
         * Show Errors
         * @access private
         */
        
    private $ShowErrors;

        
    /**
         * Connect to the database
         * @param Host localhost
         * @param User root
         * @param Pass NULL
         * @param Data test_db
         * @param Persistant false
         * @param Errors true
         * @param Type MySQL
         */
        
    function dbConnect($host$user$pass$data$persistant$errors$type)
        {
            
    $this->ShowErrors $errors;
            
    $type = (in_array($type$this->dbTypes)) ? $type "MySQL";
            if(
    $type == 'MySQL'){
                
    $this->link = ($persistant) ? @mysql_pconnect($host$user$pass) : @mysql_connect($host$user$pass);
                @
    mysql_select_db($data$this->link);
                if(
    $this->ShowErrors == true && mysql_error()){
                    echo 
    "<strong>Error Found</strong>: ".mysql_error();
                }
            }elseif(
    $type == 'MySQLi'){
                
    $this->link mysqli_connect($host$user$pass$data);
                if(
    $this->ShowErrors == true && mysqli_connect_error()){
                    echo 
    "<strong>Error Found</strong>: ".mysqli_connect_error();
                }
            }elseif(
    $type == 'PGSQL'){
                
    $this->link = ($persistant) ? pg_connect("host=$host port=5432 dbname=$data user=$user password=$pass") : pg_pconnect("host=$host port=5432 dbname=$data user=$user password=$pass");
                if(
    $this->ShowErrors == true && pg_last_error($this->link) != null){
                    print 
    "<strong>Error Found: ".pg_last_error($this->link);
                }
            }
        }

    Last edited by Shadow121; 10-25-2008 at 09:24 PM.

  2. #2
    xmakina's Avatar
    xmakina is offline x10 Lieutenant xmakina is an unknown quantity at this point
    Join Date
    May 2008
    Location
    England
    Posts
    265

    Re: PGSQL and Errors ._.

    The thing with database errors is they're caused by your SQL AND your database itself, so you *really* need to tell us what your SQL command was and what the error was before people can, realistically, help.
    IF($this->$post.content() == "SEE SIG"){
    w3Schools and Google
    }

  3. #3
    Shadow121's Avatar
    Shadow121 is offline x10 Lieutenant Shadow121 is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Centerville
    Posts
    455

    Re: PGSQL and Errors ._.

    Im trying to *make* it error by putting in wrong info.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers