0
好了,所以我的應用程序我使用PHP的PDO的MySQL,我有這個數據庫:PHP PDO的MySQL不會用引號返回文本
"Tiny & Big: Grandpa's Leftovers" - 75% off
現在由於某種原因在它的報價不會讓我將它反映到表單字段進行編輯,對任何沒有引號的條目都適用。
現在我已經檢查了我的查詢輸出,它清楚地給我的選項:
[info] => "Tiny & Big: Grandpa's Leftovers" - 75% off
所以,我徘徊爲什麼不能使用呢?
我取使用這個小功能數據:
public function fetch()
{
$this->STH->setFetchMode(PDO::FETCH_ASSOC);
return $this->STH->fetch();
}
和實際的查詢功能:
// the main sql query function
public function sqlquery($sql, $objects = array())
{
global $core;
try
{
$this->STH = $this->database->prepare($sql);
foreach($objects as $k=>$p)
{
// +1 is needed as arrays start at 0 where as ? placeholders start at 1 in PDO
if(is_numeric($p))
{
$this->STH->bindValue($k+1, (int)$p, PDO::PARAM_INT);
}
else
{
$this->STH->bindValue($k+1, $p, PDO::PARAM_STR);
}
}
return $this->STH->execute();
}
catch (Exception $e)
{
$core->message($e->getMessage());
}
$this->counter++;
$this->queries .= "<br />$sql";
}
嗯,我應該那樣做所有的時間,我把數據庫輸出到文本字段? – NaughtySquid 2013-03-17 20:39:52
修好了!所以,謝謝你,我會使用實體,因爲有時候用戶可能會把雙重,有時單一。 – NaughtySquid 2013-03-17 20:41:28
@MichaelBerkowski'htmlspecialchars'會將'ENT_QUOTES'設置爲兩者。 – 2013-03-17 20:48:11