SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 28 of 28
  1. #26
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    very nice thanks for that.

  2. #27
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 9three View Post
    I didn't modify anything lol, straight copy and paste.

    PHP Code:
    class OurDatabase
    {
        protected 
    $oConnection null;
        
        public function 
    __construct()
        {
            
    $this->oConnection = @new mysqli('localhost''root''''mysql');
            if(
    mysqli_connect_errno() > 0)
            {
                throw new 
    Exception(sprintf('Cannot connect to database: %s'mysqli_connect_error()));
            }
        }
    }

    try
    {
        
    $oDB = new OurDatabase();
        echo 
    'connected';
    }
    catch(
    Exception $oException)
    {
        echo 
    $oException->getMessage();    

    Same exact thing I only added the connected.
    So you've changed the credentials to something which you know to be incorrect and it still says connected?

    If so, you've got me!
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #28
    Non-Member
    Join Date
    Oct 2008
    Posts
    372
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed the parameters to something that would be false but it doesn't throw an exception. Just says "connected".


    EDIT:
    oh wow I didn't even notice that I actually have a database named "mysql". I guess that came with XAMPP. duuuuhhh

    It's working like a charm now, thanks!


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
  •