bind_param;类型定义字符串中的元素数与绑定变量数不匹配;

时间:2011-10-16 06:08:30

标签: php sqlbindparameter

有人能说出什么问题吗?我尝试以不同的方式做到这一点,但总是发生同样的错误:

Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of elements in type definition string doesn't match number of bind variables in *************************.php on line 397

不知道是否有帮助:(数据库表列表)

id
server_id
name
ip
port status
map
country
player_count
max_player_count
type
game

脚本的一部分:

<?
$name = $_POST['name'];  
$country = $_POST['country']; 
$ip = $_POST['ip']; 
$o = "AND";
$rest = "";
$text = "Key : ";      
////////////////////////name       
if($name!="") {
  if($rest=="") {
    $rest.="where name like % ? %";
    $text.="Name like % ? % ";
  }
  else {
    $rest.="$o name like % ? %";
    $text.="Name like % ? % ";
  }
}
///////////////////////country       
if($country!="") {
  if($rest=="") {
    $rest.="where country= ? ";
    $text.="Country = ?";
  }
  else {
    $rest.=" $o country= ? ";
    $text.=", Country = ?";
  }
}
////////////////////////ip               
if($ip!="") {
  if($rest=="") {
    $rest.="where ip = ? ";
    $text.="Ip Address = ? ";
  }
  else {
    $rest.=" $o  ip = ?' ";
    $text.=", Ip Address = ? ";
  }
}
if($rest!="") {
  $rest=$rest;
}
else {
  //die("Enter Search Parameter<br><br><br><br><br><br><br><br><br><br><br>");
}         
$stmt = $mysqli->prepare("select $search.* from $search $rest order by id"); 
///////////////////////// Error line below  397
$stmt->bind_param('sss', $name, $country, $ip);
/////////////////////////
$stmt->execute(); 
$stmt->store_result();
$num = $stmt->num_rows;

?>

0 个答案:

没有答案