Hye! This is my first question here, so sorry in advance if I don't get it right.
I want to insert pictures from a gallery in a description text by using #pic1# (#pic2# and so on) in the text and replace it with
Here is the code:
<?
$myString =$art[0][page_text];
$pics=mysql_query_assoc("select * from pages_galerie where id_page='".$id_page."'");
$count= count($pics);
for ($i=0; $i < $count; $i++) {
$search='#pic'.$i+1.'#';
$img=$pics[$i][pic];
$newString = str_replace($search, "<img src=".SITE_URL."pics/medium/".$img.">", $myString);
}
?>
It doesn't work! What do I do wrong?
$pics? (Edit the question and copy/paste some of it in there)$id_pagestems from a GET/POST variable, that's asking for a SQL injection. Also, you forgot quotes in the array key on this line$img=$pics[$i][pic];it should be$img=$pics[$i]['pic'];<?tag is not recommended. It is better to always use the long form<?php. (many PHP servers have the short tags disabled)