I’m getting error on this:
Deprecated: Function split() is deprecated in C:\xampp\htdocs\tet\search_motifasni2.php on line 10
Notice: Undefined variable: sql in C:\xampp\htdocs\tet\search_motifasni2.php on line 18
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\tet\search_motifasni2.php on line 32
doc with term:
Codes:
if (isset($_POST['Submit']))
{
//retrieve search word, trim, remove duplicate
$find = $_POST['find'];
$find = ltrim($find);
$find = rtrim($find);
$find = split(" ",$find);//line 10
$find = array_unique($find);
. . .
if($val<>" " and strlen($val)>0)
{
$sql .=" Terms = '$val' or";//line 18
}
}
. . .
$query = "SELECT * FROM document";
$result = mysql_query($query);
$num = mysql_num_rows($result);//line 32
Tried many ways but still getting the same result when searched a query.
First,
splitis deprecated: instead useexplode. (like this:$find = explode(' ', $find);which is basically the same)Also, you use both
ltrimandrtrim, I think you could just as well usetrim, which does both.The second error is thrown because the
$sqlvariable you use is not yet defined on line 18, you can’t concatenate a string to a variable that is not yet defined (actually you can, because php is very humble, but it’s not nice)It can be easily solved by putting
$sql = '';before theifstatement.The last error means
mysql_num_rowsgetsfalseas an argument, while it needs a mysql resource.$resultis false, somysql_queryreturns false, which it does when there’s an error while executing the query, see here. Does your tabledocumentexist?