Log in

View Full Version : is there anyone who can solve the error of this code?



ufuk
12-18-2006, 12:46 PM
Below code my serach.php code, and it gives maximun execution time error, that is, it is endless loop. I cant find the problem. There are some incompetence, but I cant find :( Please, help me. I strugle for 2 week for this code. This place is my last chance. Thanks a lot.


<?php
/*
$link = explode("{basla}",$mesaj);
$link = ereg_replace("{bitir}", "", $link[1]);
echo "I catched: $link";
*/
if ($q) {
$q = ereg_replace("%u0131","i",$q);
$q = ereg_replace("%u011F","g",$q);
$q = ereg_replace("%u015F","s",$q);
$q = ereg_replace("ş","s",$q);
$q = ereg_replace("Ş","S",$q);
$q = ereg_replace("ç","c",$q);
$q = ereg_replace("Ç","C",$q);
$q = ereg_replace("ı","i",$q);
$q = ereg_replace("İ","I",$q);
$q = ereg_replace("ğ","g",$q);
$q = ereg_replace("Ğ","G",$q);
$q = ereg_replace("ö","o",$q);
$q = ereg_replace("Ö","O",$q);
$q = ereg_replace("ü","u",$q);
$q = ereg_replace("Ü","U",$q);
$q = ereg_replace("Ö","O",$q);

$string=$_GET['q'];
if (!$q) {
echo "<div class=dash><center><b><img src=images/unlem.gif> How can I now ?";
die;
}
echo "<font class=link>$q related topics...</font><br><br>";
if ($sirala == 1)
$SQL="SELECT baslik,id FROM konular WHERE baslik like '%$string%' and statu='' ORDER By tarih desc";
else if ($sirala == 2)
$SQL="SELECT baslik,id FROM konular WHERE baslik like '%$string%' and statu='' ORDER By baslik";
else
$SQL="SELECT baslik,id FROM konular WHERE baslik like '%$string%' and statu=''";
}

baglan();
$sorgu=mysql_query($SQL) ;
if (!$sorgu)
{
echo "<div class=dash><center><b><img src=images/unlem.gif> How can I know ?"; exit();
}
$arguman=0;
$adet=0;
while($sira=@mysql_fetch_array($sorgu))
{
$sonuc[$arguman]=$sira["id"];
$arguman++;

}
if($string{0}!='"')
{
$pieces=explode(" ",$string);
for($i=0;$i<(count($pieces)-1);$i++)
{
if ($adi) {
$SQL="SELECT baslik FROM konular WHERE baslik like '%$pieces[$i]%' and statu=''";
}
$sorgu=mysql_query($SQL) ;
if (!$sorgu)
{ echo("<P>Error2: " . mysql_error() . "</P>"); exit();}
$i=0;
if($sira["id"]!=$sonuc[$i])
$sonuc[$arguman]=$sira["id"];
$arguman++;
$i++;
echo count("Sonuclar :$sonuc");
while($sira=@mysql_fetch_array($sorgu))
{
while($i<(count($sonuc)-1))
{
if($sira["id"]!=$sonuc[$i])
$sonuc[$arguman]=$sira["id"];
$arguman++;
$i++;
}
}
}
}
echo "<div class=div1>";
for($i=0;$i<count($sonuc);$i++)
{
$SQL="SELECT * FROM konular WHERE id='$sonuc[$i]' and statu=''";
$sorgu=mysql_query($SQL) ;
while($sira=@mysql_fetch_array($sorgu))
{
$baslik = $sira["baslik"];
echo "* <a href=\"sozluk.php?process=word&q=$baslik\"><font size=2>$baslik</font></a><br>";
}
}
$SQL="SELECT id FROM konular WHERE baslik='$q' and statu=''";
$sorgu=mysql_query($SQL);
if (!@mysql_num_rows($sorgu)){
echo "</div>";
echo "<center><font class=link><font color=white>$q</font><font class=link> there is no such a topic before";
if ($verified_durum == "on")
echo "
<form action=\"sozluk.php?process=add\" method=post>
<input type=hidden name=\"baslik\" value=\"$q\">
<input type=hidden name=\"okword\" value=\"$q\">
<input type=hidden name=okmsj value=ok>
<input type=submit class=but name=ac value=\"Then, I open topic\">
</form>
</center>
";
}
?>

apollo
01-14-2007, 07:34 AM
From the code shown, it is incomplete?


if($string{0}!='"'){ //<--No Closing Brace ***
$pieces=explode(" ",$string);
for($i=0;$i<(count($pieces)-1);$i++){ //<--No Closing Brace ***
if ($adi) {
$SQL="SELECT baslik FROM konular WHERE baslik like '%$pieces[$i]%' and statu=''";
}
$sorgu=mysql_query($SQL) ;
if (!$sorgu){ //<--No Closing Brace ***