第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將鏈接作為 href 標(biāo)簽插入數(shù)據(jù)庫(kù)

將鏈接作為 href 標(biāo)簽插入數(shù)據(jù)庫(kù)

PHP
隔江千里 2023-08-11 10:49:11
我在數(shù)據(jù)庫(kù)中插入鏈接時(shí)遇到問(wèn)題。我通過(guò)幾個(gè)條件生成鏈接,但最終,當(dāng)我嘗試在數(shù)據(jù)庫(kù)中插入鏈接時(shí)出現(xiàn)錯(cuò)誤。另外,我從數(shù)據(jù)庫(kù)中提取描述,然后將這些鏈接添加到現(xiàn)有描述中,然后更新該值。$parent_path = 'https://sitename.com/game/'.$parentSlug;$parentLink = '<a href="'.$parent_path.'">'.$parentName.'</a>';$child_path = 'https://sitename.com/game/'.$slug;$childLink = '<a href="'.$child_path.'">'.$name.'</a>'; 我在腳本運(yùn)行期間遇到幾個(gè)錯(cuò)誤未捕獲的 PDOException: SQLSTATE[42000]: 語(yǔ)法錯(cuò)誤或訪問(wèn)沖突: 1064 您的 SQL 語(yǔ)法有錯(cuò)誤;檢查與您的 MariaDB 服務(wù)器版本相對(duì)應(yīng)的手冊(cè),了解正確的語(yǔ)法,以使用附近的也是 CBD 教育部分,以幫助您在做出...時(shí)做出最佳決定。$sql = "SELECT * FROM `wpdev_postmeta` where post_id = $post_id  and meta_key = 'test'";$q = $conn->query($sql);     while($r = $q -> fetch()){     $description = $r['meta_value']; }$description 可能包含“a href 標(biāo)簽”,當(dāng)我回顯它時(shí),它變成可點(diǎn)擊的鏈接,并且無(wú)法更新數(shù)據(jù)庫(kù)中的字段。$desc = $description.'<br/>'.$parentLink.$childLink;$stmt = "UPDATE wpdev_postmeta SET  meta_value = '$desc' WHERE meta_key  = 'test' and post_id = $post_id ";      if ($conn->query($stmt)) {      echo "Record updated successfully". '<br/>';} else {      echo "Error updating record: " . '<br/>';}為了將來(lái)的參考,我是否需要先從數(shù)據(jù)庫(kù)獲取數(shù)據(jù),然后使用新的更新再次發(fā)送數(shù)據(jù),以防我不想丟失之前插入的內(nèi)容?我正在谷歌搜索但找不到合適的答案。
查看完整描述

1 回答

?
繁華開(kāi)滿天機(jī)

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個(gè)贊

如果您需要將 HTML 保存到數(shù)據(jù)庫(kù),您可以使用兩種不同的方式

  1. 使用準(zhǔn)備好的語(yǔ)句。

  2. 對(duì)所有標(biāo)簽和其他特殊符號(hào)進(jìn)行編碼,例如通過(guò)htmlentitieshtmlspecialchars

示例htmlentities

<?php

? ? $link = '<a >Check that</a>';

? ? echo(htmlentities($link, ENT_QUOTES|ENT_HTML5));

? ? // output:

? ? /*

? ? &lt;a href&equals;&quot;https&colon;&sol;&sol;stackoverflow&period;com&sol;&quot;&gt;Check that&lt;&sol;a&gt;

? ? */

?>

用于解碼為 HTML 使用html_entity_decode


<?php

? ? $encoded = '&lt;a href&equals;&quot;https&colon;&sol;&sol;stackoverflow&period;com&sol;&quot;&gt;Check that&lt;&sol;a&gt;';

? ? echo(html_entity_decode($encoded, ENT_QUOTES|ENT_HTML5));

? ? // output

? ? /*

? ? <a >Check that</a>

? ? */

?>

示例htmlspecialchars:


<?php

? ? $link = '<a >Check that</a>';

? ? echo(htmlspecialchars($link, ENT_QUOTES|ENT_HTML5));

? ? // output

? ? /*

? ? &lt;a href=&quot;https://stackoverflow.com/&quot;&gt;Check that&lt;/a&gt;

? ? */

?>

對(duì)于解碼htmlspecialchars:


<?php

? ? $encoded = '&lt;a href=&quot;https://stackoverflow.com/&quot;&gt;Check that&lt;/a&gt;';

? ? echo(htmlspecialchars_decode($encoded, ENT_QUOTES|ENT_HTML5));

? ? // output

? ? /*

? ? <a >Check that</a>

? ? */

?>


查看完整回答
反對(duì) 回復(fù) 2023-08-11
  • 1 回答
  • 0 關(guān)注
  • 201 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)