我收到很多错误:mysqli_real_escape_string()期望参数1为mysqli,boolean given
错误是mysqli_real_escape_string()需要2个参数,但只有1个项需要更新。
问题在于:
$updatequery = "
UPDATE
as_comprofiler
SET
cb_empstatustime = '".time()."'
, cb_profiel = '".mysqli_real_escape_string($value->profile->nickname)."'
, cb_empstatus = '".mysqli_real_escape_string($cb_empstatus)."'
, cb_taal = '".mysqli_real_escape_string($talen)."'
, cb_sms = '".mysqli_real_escape_string($sms)."'
WHERE
cb_boxnr = '".mysqli_real_escape_string($value->boxnumber)."'
";
以及页面的完整部分:
// elke ***
foreach($xml->consultant AS $value){
// $cb_empstatus vullen a.d.h.v activated en callstatus
if($value->activated == 0){
$cb_empstatus = 'Afwezig';
}
elseif($value->activated == 1){
if($value->callstatus == 0){
$cb_empstatus = 'Beschikbaar';
}
elseif($value->callstatus == 1){
$cb_empstatus = 'Bezet';
}
elseif($value->callstatus == 2){
$cb_empstatus = 'Pauze';
}
}
// lege variabele aanmaken
$talen = '';
$sep = '';
foreach($value->languages->language AS $taal){
$talen .= $sep;
$talen .= $taal;
$sep = '|*|';
}
// sms code omzetten naar tekst
if($value->smsavailable == 1){
$sms = 'Ja';
}
else{
$sms = 'Nee';
}
// de update query
$updatequery = "
UPDATE
as_comprofiler
SET
cb_empstatustime = '".time()."'
, cb_profiel = '".mysqli_real_escape_string($value->profile->nickname)."'
, cb_empstatus = '".mysqli_real_escape_string($cb_empstatus)."'
, cb_taal = '".mysqli_real_escape_string($talen)."'
, cb_sms = '".mysqli_real_escape_string($sms)."'
WHERE
cb_boxnr = '".mysqli_real_escape_string($value->boxnumber)."'
";
if(mysqli_query($updatequery) == false){
// foutmelding
echo 'Niet uitgevoerd:<br>'.$updatequery.'<br><br>';
}
有人提出这个想法吗?
答案 0 :(得分:1)
正如文档中所给出的,程序风格是
string mysqli_real_escape_string ( mysqli $link , string $escapestr )
其中$link
是mysqli_connect() or mysqli_init()
返回的链接标识符。您在代码中遗漏了这一点。因此,这解释了第二个错误的原因。
您的代码段中没有boxnumber
value
属性,但您仍在尝试访问其值,这解释了第一个错误