我正在尝试将用户信息存储在mysql数据库中并将其返回到浏览器窗口我获取数据父行的行号而不是应该存储在其中的数据。它已经有一段时间了(原谅双关语)因为我使用的是mysql或php。
<?php
//connect to database
include('db-connect.php');
echo "<br/> echo user email: ". $user_profile['email'];
$fb_id = $user_profile['id'];
$fb_id = mysqli_real_escape_string($dbc,$fb_id);
//mysqli_real
//check if user exists
$check_user = mysqli_query($dbc , "SELECT * FROM users WHERE fb_id = '$fb_id';");
$check_user_result = mysqli_fetch_row($check_user);
if ($check_user_result[0] == 0) {
echo ' <br/> no such user exists';
$add_user = mysqli_query($dbc , "INSERT INTO users (user_id, email, first_name, last_name, fb_id) VALUES('','".$user_profile['email']."','".$user_profile['first_name']."','".$user_profile['last_name']."','".$user_profile['id']."')");
}
else{
echo " <br/> already registered <br/> should be an facebook ID before this". $fb_id;
$get_user_db_info = mysqli_query($dbc , "SELECT * FROM users");
while($row = mysqli_fetch_array($get_user_db_info)){
// then your for loop
echo '<br/>user_id: '.$row['user_id'].'<br/>email: '.$row['user_id'].'<br/>First Name: '.$row['user_id'];
}
}
?>
任何帮助都会很棒,如果需要可以提供更多信息。
答案 0 :(得分:1)
你一遍又一遍地输出相同的值:
echo '<br/>user_id: '.$row['user_id'].'<br/>email: '.$row['user_id'].'<br/>First Name: '.$row['user_id'];
^^^^^^^ ^^^^^^^ ^^^^^^^