php - Sql parameter warning -


i have 3 tables query html form. tried many formats , conditions 1 1 comes close i'm trying achieve. i'm new , need help. not know i'm missing show out-put.

here code:

if(isset($_post['submit'])) {     $summary=$_post['summary'];     $status=$_post['status'];     $priority=$_post['priority'];      $db=mysql_connect (" ") or die ('i cannot connect database because: ' .  mysql_error());       $mydb=mysql_select_db(" "); }  $where = ''; if(isset($status) && !empty($status)){     $where .= "status ='$status' , "; } if(isset($priority) && !empty($priority)){     $where .= "priority ='$priority' , "; } if(isset($summary) && !empty($summary)){     $where .= "summary ='$summary' , "; }  $sql= "select * data $where"; $result = mysql_query($sql);   if (mysql_num_rows($result)==0){      echo "no match found";  }else{      while($row = mysql_fetch_array($result)) {         echo $not_completed=$row['not completed'];         echo $completed=$row['completed'];         echo $miscommunications =$row['miscommunications'];         echo $not_given_access=$row['not given access'];         echo $unskilled=$row['unskilled'];         echo $missing_parts=$row['missing parts'];         echo $high=$row['high'];         echo $medium=$row['medium'];         echo $low=$row['low'];         echo $efirst_name =$row['efirst_name'];         echo $elast_name=$row['elast_name'];         echo $employee_id=$row['employee_id'];     } } 

and here html form:

<select name="status">      <option>status</option>     <option>completed</option>     <option>not completed</option> </select>  <select name="priority">      <option>priority</option>     <option>high</option>     <option>medium</option>     <option>low</option> </select>   <select name="summary">      <option>summary</option>     <option>miscommunications</option>     <option>not given access</option>     <option>unskilled</option>     <option>missing parts</option> </select>  <div align="right"><input type="submit" value="search"> 

i warning of: warning: mysql_num_rows() expects parameter 1 resource, boolean given in c:\wamp\www\search.php on line 191 // "if (mysql_num_rows($result)==0)"...

all suggestions welcomed. thanks.

$conditions = array();  if(isset($status) && !empty($status)){   $conditions[] = "status ='$status'"; } if(isset($priority) && !empty($priority)){   $conditions[] = "priority ='$priority'"; } if(isset($summary) && !empty($summary)){   $conditions[] = "summary ='$summary'"; }  $where = ''; if (!empty($conditions)) {   $where = "where " . implode(' , ', $conditions); }  $sql= "select * data $where"; 

edit: can please post result of this:

if(isset($_post['submit'])) {     $summary=$_post['summary'];     $status=$_post['status'];     $priority=$_post['priority'];      $db=mysql_connect (" ") or die ('i cannot connect database because: ' . mysql_error());       $mydb=mysql_select_db(" "); } else {     echo "i might not connected database..."; }  echo 'connection error? ' . mysql_error();  echo 'ping result: ' . mysql_ping() === false ? 'not connected.' : 'connected.';  $conditions = array();  if(isset($status) && !empty($status)){   $conditions[] = "status ='$status'"; } if(isset($priority) && !empty($priority)){   $conditions[] = "priority ='$priority'"; } if(isset($summary) && !empty($summary)){   $conditions[] = "summary ='$summary'"; }  $where = ''; if (!empty($conditions)) {   $where = "where " . implode(' , ', $conditions); }  $sql= "select * data $where";  echo "sql command: $sql";  $result = mysql_query($sql);   echo 'query error? ' . mysql_error();  if (mysql_num_rows($result)==0){      echo "no match found";  }else{      while($row = mysql_fetch_array($result)) {         echo $not_completed=$row['not completed'];         echo $completed=$row['completed'];         echo $miscommunications =$row['miscommunications'];         echo $not_given_access=$row['not given access'];         echo $unskilled=$row['unskilled'];         echo $missing_parts=$row['missing parts'];         echo $high=$row['high'];         echo $medium=$row['medium'];         echo $low=$row['low'];         echo $efirst_name =$row['efirst_name'];         echo $elast_name=$row['elast_name'];         echo $employee_id=$row['employee_id'];     } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -