Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Problems with match against -


im trying make search engine php , mysql , im using match agains.

however im having problem (probably syntax) driving me crazy.

here code:

<?php  $busqueda= $_get["words"]; require("conectdb.php");  if ($busqueda<>''){      $trozos=explode(" ",$busqueda);     $numero=count($trozos);    if ($numero==1) {      $cadbusca="select * post contenido '%$busqueda%' or titulo '%$busqueda%'";    } elseif ($numero>1) {       $cadbusca="select * , match ( 'titulo', 'contenido' ) against ( '$busqueda' )  score post match ( 'titulo', 'contenido' ) against ( '$busqueda' ) order score desc";  }   $result=(mysql_query($cadbusca));  while($info = mysql_fetch_array($result)) {    echo $info["id"]." ".$info["titulo"]." ".$info["contenido"];  }  } ?>  

here error after more 1 word search:

warning: mysql_fetch_array(): supplied argument not valid mysql result resource in /home1/foodbook/public_html/search/wordsearch.php on line 19 

the fields set fulltext....

thx

the warning means query failed. if query fails, mysql_query() returns boolean false , can retrieve error message mysql_error():

$res = mysql_query($cadbusca); if ($res === false) {       die("query failed: " . mysql_error()); } 

your code assuming query succeeded , attempts fetch row false value, not valid result handle. bad practice assume query succeed. if query string syntactically valid, there's many many many other ways failure can occur, , should check success (or failure) @ every step.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -