私はPHPに新しい、私のようにエラーを取得しています午前中のユーザーID:お知らせ:未定義のインデックス:
Notice: Undefined index: userID in echo "<a href='home.php?userID=".$row['userID'] . "'>".$row['userName']." ".$row['userEmail']."</a><br/>";
home.php
$sql = 'SELECT userName, userEmail FROM tbl_users';
$stmt = $dbCon->prepare($sql);
$stmt->setFetchMode(PDO::FETCH_ASSOC); //allows you to refer to them by column name rather than by number
$stmt->execute();
while ($row = $stmt->fetch())
{
echo "<a href='home.php?userID=".$row['userID'] . "'>".$row['userName']." ".$row['userEmail']."</a><br/>"; //builds the link
}
iはthis linkに続き、中に以下のコードを追加しますhome.php & signup.php、それは私のために働いていませんでしたが、私は間違いを犯しましたか?
//Initializing variable
$userID = "";
//isset()
$userID = isset($_POST['userID']) ? $_POST['userID'] : '';
//empty()
$userID = !empty($_POST['userID']) ? $_POST['userID'] : '';
編集
私はそのリンクで答えをたどっているため、この質問が重複していないが、それは私のために働いたdid't。
'print_r($ row)' –
sqlで 'userID'を選択しませんでした。あなたは 'userName、userEmail'のみを選択します。 –
@u_mulder Thanskはサポートのためにたくさん..... –