douxi8119 2014-02-18 14:35
浏览 36
已采纳

从mysqli选择返回错误的数字值

i am attempting to store the users info in mysql db and return it to the browser window i am getting the row number of the data father than the data that should be stored in it. its been a while(pardon the pun) since i used mysql or 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'];
}
}

?>

any help would be great and can provide more info if required.

  • 写回答

1条回答 默认 最新

  • dongyong2063 2014-02-18 14:40
    关注

    You're outputting the same value over and over again:

    echo '<br/>user_id: '.$row['user_id'].'<br/>email: '.$row['user_id'].'<br/>First Name: '.$row['user_id'];
                                ^^^^^^^                        ^^^^^^^                             ^^^^^^^
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)