my query below
$sorgum = "SELECT kolon_etiketler, kolon_yazar, kolon_baslik, kolon_resim_baslik, kolon_resim_url, kolon_yazi, kolon_ytarihi FROM tb_yazilar WHERE kolon_statu = 'onay' AND kolon_yazar ='".tire_bosluk_olsun($_GET["rd_ozne"])."' AND kolon_baslik ='".tire_bosluk_olsun($_GET["rd_nesne"])."' ORDER by kolon_onaytarihi DESC";
$sorgum = "SELECT kolon_etiketler, kolon_yazar, kolon_baslik, kolon_resim_baslik, kolon_resim_url, kolon_yazi, kolon_ytarihi FROM tb_yazilar WHERE kolon_statu = 'onay' AND kolon_yazar ='".tire_bosluk_olsun($_GET["rd_ozne"])."' AND noktalamasiz(kolon_baslik) ='".tire_bosluk_olsun($_GET["rd_nesne"])."' ORDER by kolon_onaytarihi DESC";
working: AND kolon_baslik = ...
non-working: AND noktalamasiz(kolon_baslik) = ...
from address bar, $_GET['nesne']
is coming. This is the without-any-punctuation syntax of article's title. Also space character is replaced with dash character.
In my MySQL table, article title is in normal form with punctuation and with spaces btw words.
example:
in my MySql table: "Is John's Clock Working?", it becomes in url address "Is-Johns-Clock-Working"
Is there any thing I can do with non-working query? I can't give to its removed punctuation to $_GET['nesne']
so I need to compare the values of without-punctuation-state of the title row in mysql table and $_GET['nesne']
. Maybe I am on very wrong way so please lead me the correct way to handle automatic way of linking with allowing user to enter punctuated titles and only 1 title column in mysql table.
noktalamasiz = a custom-php function that removes all punctuation.
tire-bosluk-olsun = replace the dash with space. So if my very first title doesn't include any punctuation but only space btw words, then I would have no difficulty and only use working sql.
function tire_bosluk_olsun ($tireli)
{
$tireli = trim($tireli);
$tireli = str_replace('-',' ',$tireli);
return $tireli;
}
function noktalamasiz($noktalamali) {
$noktalamali = trim($noktalamali);
$ara = array('.',',',';',':','...','?','!','-','—','/','\\','“','”','‘','’','"','\'','(',')','[',']','’','{','}','*','&','#','^','<','>','|');
$degistir = array('','','','','','','',' ','','','','','','','','','','','','','','','','','','','','','','',);
$noktalamali = str_replace($ara,$degistir,$noktalamali);
return $noktalamali;
}
if my query involves noktalamasiz custom function
as this : noktalamasiz(kolon_baslik)
; then I got empty screen without any warning- notice or error. I am working with -1 error level.
$sorgum = "SELECT kolon_etiketler, kolon_yazar, kolon_baslik, kolon_resim_baslik, kolon_resim_url, kolon_yazi, kolon_ytarihi FROM tb_yazilar WHERE kolon_statu = 'onay' AND kolon_yazar ='".tire_bosluk_olsun($_GET["rd_ozne"])."' AND noktalamasiz(kolon_baslik) ='".tire_bosluk_olsun($_GET["rd_nesne"])."' ORDER by kolon_onaytarihi DESC";
if ($beyan = $db_baglanti->prepare($sorgum))
{
/* execute statement */
$beyan->execute();
/* bind result variables */
$beyan->bind_result($etiketler, $yazar, $baslik, $resim_baslik, $resim_url, $yazi, $ytarihi);
/* fetch values */
while ($beyan->fetch())
{
echo '<div class="sol-icerik-kapsar">'."\r\n";
echo "\t".'<h1>'.$baslik.'</h1>'."\r\n";
echo "\t".'<img class="mansetresim" width="120" height="160" src="'.sitenin_koku.'img/manset/'.$resim_url.'" alt="'.$resim_baslik.'" title="'.$resim_baslik.'" />'."\r\n";
echo "\t".'<p><a href="'.sitenin_koku.'yazılar/'.bosluklar_tire_olsun($yazar).'">'.$yazar.'</a>'.' - '.turkcetarih('j F Y',$ytarihi).'</p>'."\r\n";
echo "\t".'<p>'.$yazi.'</p>'."\r\n";
echo "\t".'<p>'.$etiketler.'</p>'."\r\n";
echo '</div>'."\r\n";
}
/* close statement */
$beyan->close();
}
You can't use php functions in mysql query. That's not how it works. For your purpose I'd create a new row which is filled with output of your php function noktalamasiz()
.