Page 1 of 1

apache stop when working with PDO

PostPosted: 21. August 2009 08:46
by develturk
XAMPP 1.7.1 under the Vista.
When i use the simple PDO functions apache stop immediately!

Code: Select all
try {
    $hostname = "localhost";            //host
    $dbname = "example";            //db name
    $username = "root";            // username like 'sa'
    $pw = "";                // password for the user

    $options = array(PDO::ATTR_AUTOCOMMIT=>FALSE);
   
    $dbh = new PDO ("mysql:host=$hostname;dbname=$dbname","$username","$pw",$options);
    $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );

    $res = $dbh->query("SELECT * FROM articles");
    while ($row = $res->fetch(PDO::FETCH_ASSOC)){
        echo $row['article']."<br />";
    }
   
    //$sth->execute();
    //$yellow = $sth->fetchAll();
   
    print_r($row);
   
   
   
  } catch (Exception $e) {
    //echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    echo $e;
   
    exit;
  }