我在這裏做錯了什麼?
// INSERT: if we have a name to add...
if($_POST['email'] & $_POST['job_id']) {
// little bit of cleaning...
$email = mysql_real_escape_string($_POST['email']);
$job_id = mysql_real_escape_string($_POST['job_id']);
// insert new name into table
$sql = "INSERT INTO job_applications (id, email, job_id) VALUES ('','$email,'$job_id')";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
} // end if
我使用「&」,但沒有運氣,是有一定的語法以包括變量?只需要「if($ _ POST [])」一次超過一個值?
你想知道這兩個值是否都是非空的? '&'是按位AND運算符,'&&'是_邏輯_AND。 –
不要這樣做。 'mysql_real_escape_string($ _ POST ['email']);'使用綁定參數和準備語句。 – Kermit