I get the following error ...
Parse error: syntax error, unexpected T_AS in .... \ index.php on line 98
for the following script ...
<?php
try {
$db = new PDO('mysql:host=localhost;dbname=db', 'user', 'pw');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->beginTransaction();
$stmt = $db->prepare("SELECT * FROM tablename");
$stmt->execute();
while($db->fetch(PDO_FETCH_ASSOC) as $row) {
$id= $row['id'];
$name= $row['name'];
}
$db->commit();
}
catch (PDOException $e)
{
$db->rollback();
echo "There was a system error.<br>".$e->getMessage();
}
?>
Any idea what throws an error? I checked the missing semicolons, commas and works, but received nothing!
source
share