-2

It says:

  1. Warning: Missing argument 1 for users_data()
  2. Notice: Undefined variable: user_id
  3. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given

My function:

function users_data($user_id)
{
        $data =array();
        $user_id = (int)$user_id;

    $query = mysql_query("SELECT * FROM `sun` WHERE `user_id` ='$user_id'");
    $user_data = mysql_fetch_array($query);
    return $user_data;
}

What to do?

I know that $user_id is not defined tell me how to define $user_id

I have done $user_id = $_SESSION['use_id'];; then it says undefined index...

Then i use $sql = "Select * from users Where user_id= ???" this is where i got stuck

Can anyone tell me how to solve this?

Please don't tell me to add user_id = 1,2,3 etc. because I am working on Login and Registration Form and Displaying users data.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • You are not passing argument for $user_id in your query – Umesh Aawte Jul 18 '15 at 06:25
  • 1
    There are dozens of examples out there. Some of them even use modern APIs (mysqli/PDO) rather than PHP's long since deprecated mysql_ API – Strawberry Jul 18 '15 at 07:12
  • Wild guess: you haven't called mysql_connect before calling mysql_query. Have a look at the manual: https://secure.php.net/manual/en/function.mysql-query.php – Tieson T. Jul 18 '15 at 07:53

1 Answers1

0
From warning 1 , its clear that you didnt pass $user_id to function


users_data($user_id) // where is $user_id??? you may have called function like users_data() 


Try to pass $user_id to users_data function, because warnings 2 and 3 depends on warning 1.

Unni Babu
  • 1,839
  • 12
  • 16
  • Okay thank you, but I have made a Login and Registeration Form, and i want when the person login it shows his name and email... i had done email part correctly because i use sql_query and ($row=mysql_fetch_assoc($query_run)){ $dbemail = $row['email']; $dbpassword = $row['password']; if($email == $dbemail && $password_hash == $dbpassword){ .... but now i want name too so help me – Pranay Rangne Jul 18 '15 at 06:38