Hi,
ive written the following php code. its a part of an admin form to add a text.
when adding the text %bild[xx] the script is supposed to swap that with the link to the picture already stored in the mysql db.
it works perfectly fine until the $id variable reaches "100".
I dont understand why it works for every number from 1 till 99 but not for a bigger one than 100.
I mean $id is not fixed to two digits.
Anybody any idea?
Thanks!
ive written the following php code. its a part of an admin form to add a text.
when adding the text %bild[xx] the script is supposed to swap that with the link to the picture already stored in the mysql db.
it works perfectly fine until the $id variable reaches "100".
I dont understand why it works for every number from 1 till 99 but not for a bigger one than 100.
I mean $id is not fixed to two digits.
Code:
$text = $_POST['text'];
$get = 'SELECT * FROM bild order by bild_id desc';
$select = mysql_query($get, $link);
$bildende = (mysql_num_rows($select)+1);
$id = 1 ;
while($id < $bildende)
{
$findme = "%bild[$id]";
$pos = strpos($text, $findme);
if ($pos === false) { }
else {
$get2 = "SELECT bild FROM bild where bild_id='$id'";
$repl = mysql_query($get2, $link);
$repl = mysql_fetch_array($repl);
$repl = $repl['bild'];
$repl1 = "%bild[$id]";
$text = str_replace($repl1,$repl,$text);
}
$id++;
}
Thanks!
Comment