我需要修改這個源代碼php腳本代碼。當我與開關的情況下修改我有一個錯誤的text1沒有價值,當我給值的text1需要幫助來修改php腳本與開關案例
$query = "INSERT INTO mytable(text_name, text_image, text_detail) VALUES (:name, :image, :detail) ";
$query_params = array(
':name' => $_POST['text_name'],
':image' => $_POST['text_image'],
':detail' => $_POST['text_detail ']
);
向(像)這
switch("text1" || "tex2" || "text3"){
case "text1":
$query = "INSERT INTO comments (text_name, text_image, text1_detail)
VALUES (:name, :image, :detail) ";
//Update query
$query_params = array(
':name' => $_POST['text_name'],
':image' => $_POST['text_image'],
':detail' => $_POST['text1_detail']
);
break;
case "tex2":
$query = "INSERT INTO comments (text_name,text_image, text2_detail)
VALUES (:text_id, :image, :detail) ";
//Update query
$query_params = array(
':name' => $_POST['text_name'],
':image' => $_POST['text_image'],
':detail' => $_POST['text2_detail ']
);
break;
case "text3":
$query = "INSERT INTO comments (text_name, text_image, text3_detail)
VALUES (:text, :image, :detail) ";
//Update query
$query_params = array(
':name' => $_POST['text_name'],
':image' => $_POST['text_image'],
':detail' => $_POST['text3_detail'],
);
break;
default: echo "Something is wrong fuckingshit!! Give me at least text1 or text2 or text3 !!!";
}
,但我得到錯誤的text1沒有價值當我給那裏text1,有什麼不對?有什麼建議麼?
當一切都失敗了,閱讀手冊http://uk1.php.net/manual/en/ control-structures.switch.php – RiggsFolly
'switch(「text1」||「tex2」||「text3」)''變成'switch(1)'本質上,爲什麼它不會匹配字符串。根據習慣還要考慮更多的用戶名。 – mario
謝謝,我現在看到 – user3305355