-1
//function to add bm
function add_bm($new_url, $email)
{
$db = $this->dbm;
$this->new_url = $new_url;
$this->email = $email;
$sql = "select * from bookmark where email='$this->valid_user' and bm_URL='$this->new_url'";
if(!$stmt = $db->conn->query($sql))
{
echo "query failed: (" . $db->conn->errno . ") " .$db->conn->error;
}else{
//echo "can check";
//return true;
//row count
if($stmt->num_rows > 0){
echo "<b><br>Sorry ! <br> The URL had already been added . </b> ";
return false;
}else{
//return true;
// prepare and bind
$stmt = $db->conn->prepare("INSERT INTO bookmark (email, bm_URL,) VALUES (?,?)");
$stmt->bind_param("ss", $this->email, $this->new_url);
// set parameters and execute
if($stmt->execute()){
$stmt->close();
$db->conn->close();
return true;
}
}
}
}
看[bind_param(http://php.net/manual/en/pdostatement.bindparam.php) –
你在你準備好的聲明中有語法錯誤,因爲你絕對沒有錯誤處理和簡單地假設什麼都不會發生錯誤,你把由失敗的準備和運行返回的布爾錯誤,導致進一步的混亂。 –
Typo'bm_URL,'。你應該到處都有約束力。 – chris85