我可以知道如何從$ query中傳遞值,如果其中有值的話。如果它是空的,我仍然需要傳遞變量。雖然變量確實存在於sql數據庫中,但我仍然收到未定義變量的錯誤。傳遞變量值
<?php
include("dbconnect.php");
include("header.php");
if (isset($_POST['btn'])) {
$uname = $MySQLi_CON->real_escape_string(trim($_POST['user_name']));
$email = $MySQLi_CON->real_escape_string(trim($_POST['user_email']));
$upass = $MySQLi_CON->real_escape_string(trim($_POST['password']));
$enroller_id_n = $MySQLi_CON->real_escape_string(trim($_POST['enroller_id_n']));
$enrolled_id_n= $MySQLi_CON->real_escape_string(trim($_POST['enrolled_id_n']));
$direction = $MySQLi_CON->real_escape_string(trim($_POST['direction'])) ;
$new_password = password_hash($upass, PASSWORD_DEFAULT);
$query = $MySQLi_CON->query("select * from personal where enroller_id='".$enroller_id_n."'");
if($query){
while ($row = $query->fetch_array()) {
$enroller_id3 = $row['enroller_id'];
$left_mem = $row['left_mem'];
$right_mem = $row['right_mem'];
$test = "left_mem";
$test2 = "right_mem";
$direc = $direction;
}
}
}
?>
從'$ query'值傳遞給*,其中*? –
您是否在$ query上嘗試了print_r?結果是什麼? –
傳遞$ query的變量,例如$ left mem和$ right mem。這裏的問題是我得到未定義的變量,因爲我的個人登記員ID是空的 – stackoverflow