ziedinjsh Posted October 23, 2011 Report Share Posted October 23, 2011 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given if($_POST){ $q = $_POST['keytitle']; $sql_res = mysql_query("select articles.id, articles.title, articles2.id, articles2.title from articles, articles2 where title like '%$p%' order by id desc"); echo "<div class='search_box' align='left'>"; while($data = mysql_fetch_array($sql_res)){ $keytitle = $data['title']; if(strlen($keytitle) > 50) $keytitle = substr($keytitle, 0, 30).'...'; $title = "<b><a href='index.php?s=read&id=".$data['id']."'>» ".$keytitle."</a></b><hr style='border-color:#000'>"; echo $title; } echo "</div>"; } šitā neiet Quote Link to comment Share on other sites More sharing options...
Val Posted October 23, 2011 Report Share Posted October 23, 2011 (edited) Atšķirību starp $p un $q redzi? Pieliec arī pārbaudi un uz kverija atgriezto ierakstu skaitu. Edited October 23, 2011 by Val Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 23, 2011 Author Report Share Posted October 23, 2011 p nominīju uz q un tāpat nekas nemainās! Quote Link to comment Share on other sites More sharing options...
briedis Posted October 23, 2011 Report Share Posted October 23, 2011 (edited) Atkal un atkal šī pati kļūda. Kāds kādreiz arī izlasa piespraustos topikus? http://php.lv/f/topi...esult-resource/ Edited October 23, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
nikidijs Posted October 23, 2011 Report Share Posted October 23, 2011 @briedis - Viens ir izlasīts no A-Z. Tas par "can not modify header ...". Līdz pārējiem kautkā pagaidām "ruki ne dohodjat" :)) Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted October 23, 2011 Report Share Posted October 23, 2011 (edited) Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given $sql_res = mysql_query("select articles.id, articles.title, articles2.id, articles2.title from articles, articles2 where title like '%$p%' order by id desc"); Un neies arī, jo ir nepareizs kverījs , ja izmanto 2 vai vairāk tabulas ar vienādiem lauku nosaukumiem tad janorāda pēc kuras TABULAS lauka tad īsti jākārto/ jāatlasa dati TEV ir select articles.id, articles.title, articles2.id, articles2.title from articles, articles2 where title like '%$p%' order by id desc"); ------ izdomā pats kur ir kļūda... Edited October 23, 2011 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
nikidijs Posted October 23, 2011 Report Share Posted October 23, 2011 Sanāk ka vienas tabulas rinda nedrīkst būt vienāda ar citas tabulas rindu ? Pareizi sapratu ? Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted October 23, 2011 Report Share Posted October 23, 2011 (edited) Sanāk ka vienas tabulas rinda nedrīkst būt vienāda ar citas tabulas rindu ? Pareizi sapratu ? Ne vienmēr, var būt situācijas ka var būt vienādi... bet ne pie šāda kverija nu padoma loģiski .. , kā lai SQL zin pēc kuras tabulas title meklēt ?? nesšķiet loģiskāk šādi: --- articles.id, articles.title, articles2.id, articles2.title from articles, articles2 where articles.title like '%$p% OR articles2.title like '%$p% ... --- Edit: piedevām ko darīsi ja ID dublēsies?? tas pats ar tiitle lauku ? teiksim vienā tabulā būs 99 | kakis ortā tabulā 99 | kakis maisaa kverijs atgriezīs abus ierakstus , un abiem būs VIENĀDS id , ko veksmīgi iebarosi Linkam .. attiecīgi bus 2 linki ar daždiem nosaukumiem, bet vienādiem ID .. no kuras tabulas ņemsi datus ?? ( random principā ?? ) Edited October 23, 2011 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
nikidijs Posted October 23, 2011 Report Share Posted October 23, 2011 @Grey_Wolf - no pirmās. Jo es personīgi otro būtu rakstijis "kakis_maisa" nevis "kakis maisa" ! Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted October 23, 2011 Report Share Posted October 23, 2011 (edited) @Grey_Wolf - no pirmās. Jo es personīgi otro būtu rakstijis "kakis_maisa" nevis "kakis maisa" ! Tev atgrieztu ABUS rezultātus %kakis% atgriezīs gan kakis, gan kakis maisaa , kakis_maisa gan maisa kakis etc... JEBKURU stringu kurš saturēs kakis vismaz pēc tava kverija , palasi tāču SQL sintaksi, ko nozīmē simbols % Edited October 23, 2011 by Grey_Wolf Quote Link to comment Share on other sites More sharing options...
nikidijs Posted October 23, 2011 Report Share Posted October 23, 2011 Noteikti palasīšu... :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.