Php 显示项目的正确ID(例如图像)[';,1,2,3,';]
我需要为项目图像显示正确的ID。 我有两张桌子。一个包含id、标题、文本和图像的文件。 第一节参考文献是正确的:Php 显示项目的正确ID(例如图像)[';,1,2,3,';],php,pdo,Php,Pdo,我需要为项目图像显示正确的ID。 我有两张桌子。一个包含id、标题、文本和图像的文件。 第一节参考文献是正确的: <?php $st = $dbh->query("SELECT * FROM `info` "); $st->execute(array($_GET['media'])); foreach ($st as $post): $title = $post['title']; $image = $post['image']; $id = $post
<?php
$st = $dbh->query("SELECT * FROM `info` ");
$st->execute(array($_GET['media']));
foreach ($st as $post):
$title = $post['title'];
$image = $post['image'];
$id = $post['id']; ... ->
根据这些,数据库显示的图片,但不正确
有人能帮我解决这个问题吗?解决方案:我们需要一个可读的字符串 函数示例:
function clean_item_str($string){
return preg_replace('/[^a-zA-Z0-9_]/', '', $string);
}
function clean_item_str($string){
return preg_replace('/[^a-zA-Z0-9_]/', '', $string);
}