Why does this pdo::mysql code crash on windows???
<?php
$username = "root";
$password = "";
try {
$dsn = "mysql:host=localhost;dbname=employees";
$dbh = new PDO($dsn, $username, $password);
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected to database<br />" ;
$dbh->exec("DROP TABLE IF EXISTS vCard;");
$dbh->exec("DROP TABLE IF EXISTS emp;");
$table = "CREATE TABLE vCard(
id INT(4) NOT NULL PRIMARY KEY,
firstName VARCHAR (255),
lastName VARCHAR (255),
office VARCHAR (255),
homePh VARCHAR (13),
mobilePh VARCHAR (13))";
$dbh->exec($table);
$dbh->beginTransaction();
$dbh->exec("INSERT INTO vCard(id, firstName, lastName, office, homePh, mobilePh)
VALUES (4834, 'Randy', 'Lewis', 'SR. Front End Developer', '631-842-3375', '917-435-2245');");
$dbh->exec("INSERT INTO vCard(id, firstName, lastName, office, homePh, mobilePh)
VALUES (0766, 'Frank', 'LaGuy', 'Graphic Designer', '631-789-8244', '917-324-9897');");
$dbh->exec("INSERT INTO vCard(id, firstName, lastName, office, homePh, mobilePh)
VALUES (6684, 'Donnie', 'Dolemite', 'COO', '631-789-9482', '917-234-1222');");
$dbh->exec("INSERT INTO vCard(id, firstName, lastName, office, homePh, mobilePh)
VALUES (8569, '', 'McLovin', 'Actor', '631-842-9786', '917-987-8944');");
$dbh->commit();
echo "Data entered successfully<br/><br/>";
$sql = "SELECT * FROM vCard"; // WHERE firstName = 'Donnie'";
$results = $dbh->query($sql);
foreach ($results as $id){
echo "SSN: ". $id['id']." ";
echo "First Name: ". $id['firstName']." ";
echo "Last Name: ". $id['lastName']."<br/>";
}
}
catch (PDOException $e) {
echo "Failed: " . $e->getMessage();
$dbh->rollback();
}
?>
basically this line of code is what triggers Apache to crash..
$sql = "SELECT * FROM vCard";
If I try to select one value like 'id' it'll ... when I try to select more than one value "*" it crashes??????