データベースを使用してギャラリー用の PHP スクリプトを作成しようとしている初心者です。最近、スクリプトとデータベースを変更して、ギャラリーが「photo_caption. ギャラリーは機能しますが、データベースに引用符が含まれている場合 (たとえば、タイトル Nature's Garden And Colors )、スクリプトは引用符の前の部分をプルするだけで (ここでは、キャプション全体ではなく Nature という単語のみ Nature's Garden And Colors)、リンクを切断します。 . 現在、リンク構造は次のよう/viewgallery.php?cname=Colorado%20Journies&pcaption=Nature'sGardenAndColors
になっていますが、問題があるため、次のように表示されます/viewgallery.php?cname=Colorado%20Journies&pcaption=Nature
この問題の回避策はありますか? $_GET ステートメントを作成して、引用符を含む完全な photo_caption を取得するにはどうすればよいですか? 助けてくれてありがとう...
このコードを使用して、リンクのフォトキャプションを取得します
$pcaption = isset($_GET['pcaption']) ? ($_GET['pcaption']) : 0;
if( $pcaption ) {
$result = mysql_query( "SELECT photo_caption, photo_description, photo_filename,photo_keywords FROM gallery_photos WHERE photo_caption='".addslashes($pcaption)."'" );
list($photo_caption, $photo_description, $photo_filename, $photo_keywords) = mysql_fetch_array( $result );
$nr = mysql_num_rows( $result );
mysql_free_result( $result );
$p_caption = $photo_caption;
$p_description = $photo_description;
$p_keywords = $photo_keywords;
//fill pid_array with sorted pids in current category
$result = mysql_query( "SELECT photo_caption FROM gallery_photos WHERE category_name='".addslashes($cname)."' ORDER BY photo_caption" );
$ct = mysql_num_rows( $result );
while ($row = mysql_fetch_array($result)) {
$pid_array[] = $row[0];
}
mysql_free_result( $result );
if( empty($nr ) )
{
print "%%%%NR is $nr";
$result_final = "\t<tr><td>***No Photo found</td></tr>\n";
}
else
{
$result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_name='".addslashes($cname)."'" );
list($category_name) = mysql_fetch_array( $result );
mysql_free_result( $result );
$result_final = "
<div class=limagePage>
<div class=llink><a href='viewgallery.php'>ALBUMS</a><span class=arrow>>></span><a href='viewgallery.php?cname=$cname>$category_name'</a></div>
";
// display previous and next links if more than one photo
if ($ct > 1)
{
$key = array_search($pcaption , $pid_array);
$prev = $key - 1;
if ($prev < 0) $prev = $ct - 1;
$next = $key + 1;
if ($next == $ct) $next = 0;
//$cname = str_replace(" ","_",$cname);
//$pcaption=str_replace(" ","_",$pcaption);
$result_final .= "<div class='prevnext'>";
$result_final .= "<span class='prev'><a href='viewgallery.php?cname=$cname&pcaption=".$pid_array[$next]."'><img src='photos/assets/left.png' border='0' ></a></span>";
$result_final .= "<span class='next'><a href='viewgallery.php?cname=$cname&pcaption=".$pid_array[$prev]."'><img src='photos/assets/right.png' border='0' ></a></span>";
$result_final .= "</div>";
}
}
//$cname = str_replace(" ","_",$cname);
//$pcaption=str_replace(" ","_",$pcaption);
$result_final .= "<div class=limage><table><tr><td><table class=image><tr>\n\t<td><a href='viewgallery.php?cname=$cname&pcaption=".$pid_array[$next]."'><img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_keywords."' /></a>
<div class=caption>".$photo_caption."</div>
<div class='excerpt'>".$photo_description."</div>
</td>
</tr></table></td></tr></table><div class=underline></div></div>
<!-- .limagePage --></div> ";