0
정규식에 대해이 이상한 상황이 발생합니다. I는 ID가 설정되어있는 경우 다음 index.php
로 리디렉션되지 않을 경우 공간 분리 된 두 개의 단어가 있었다 제 이것은 의 index.php
$title = "This is a title";
$id = "5";
$queryc = $db->prepare("SELECT * FROM categories WHERE id = :id");
$queryc->bindParam(':id', $id, PDO::PARAM_INT);
$queryc->execute();
/*** fetch the results ***/
$resultc = $queryc->fetchAll();
$count = count($resultc);
if ($count > 0)
{
foreach($resultc as $rowc)
{
$cat_name = htmlentities($rowc['cat_name'], ENT_QUOTES, 'utf-8');
$cat_name = stripslashes($cat_name);
}
}else {
//redirect is a function
redirect("index.php");
}
echo "
<td width='57%' height='126' class='bord' ><a href='$cat_name-$id.htm'
class='title_style'>" . $title . "</a><br>";
$cat_name
을 확인하고 싶어하거나 일부를 제외하고도 문자를 강조 수도 chars. 이를 위해 전에서 의 .htaccess를
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^[email protected]#$%^&*(){}]+)-(\d+)\.htm$ file.php?id=$2 [L]
사용 결과는 내가 $ ID가이 같이 표시됩니다 브라우저에서
if(isset($_GET['id']))
{
$id = (int) $_GET['id'];
if($id == 0)
{
redirect("index.php");
exit;
}
}
else
{
redirect("index.php");
exit;
}
설정되어 있는지 확인하고 싶었을 보여줍니다 file.php : mydomain.com/auto 경매 5.htm
내 문제는 다음과 같습니다 $cat_name = auto auction;
(공백에주의하십시오) 작동하지 않지만 공간이없는 $cat_name = autoauction;
이면 작동합니다.
공백이있을 때 어떻게 작동합니까?
"설정되지 않음"이란 무엇을 의미합니까? 전달 된 문자열이 "범주 이름"또는 "범주 이름 -0"이라는 의미입니까? 왜 PHP를 사용해야합니까? .htaccess 파일에서 이미 사용하고있는 정규식을 사용하여 해당 숫자가 있는지 확인할 수는 없습니까? – dcasadevall
은 $ id = 5라고 말하면 url은 mydomain.com/auto 경매 - 5.htm이 될 것이며이 mydomain.com/auto 경매 - 2045.htm을 실행하면 2045 년 이후로 index.php로 리디렉션하고 싶습니다. 존재하지 않습니다. – Rocks