我的SELECT
语句看起来像这样:
$db_Host = "localhost";
$db_Username = "neparc";
$db_Pass = "***************";
$db_Name = "nepareptileclub";
try
{
$db = new PDO ('mysql:host = '.$db_Host.' ; dbname = '.$db_Name , $db_Username, $db_Pass);
$db -> setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $db -> query("SELECT stateinital FROM states");
while($row = $result -> fetch(PDO::FETCH_ASSOC))
{
echo $row['stateinital'] . "<br />";
}
}
catch(PDOException $e)
{
echo "Error: " . $e -> getMessage() . ".";
}
但是如果我将select语句更改为以下语句就可以了:
$result = $db -> query("SELECT stateinital FROM nepareptileclub.states");