Cannot solve this

Website URL

(studynow.free.nf)[studynow.free.nf]
while logging in

Error Message

Fatal error : Uncaught Error: Array callback must have exactly two elements in /home/vol16_2/infinityfree.com/if0_35990726/htdocs/public/login.php:5 Stack trace: #0 {main} thrown in /home/vol16_2/infinityfree.com/if0_35990726/htdocs/public/login.php on line 5

Other Information

Trying to fetch database using mysqli

code

$sql = "select `user_id`, `password` from `users` where `username` = '$user';";

$qdata = $conn->query($sql);
if ($qdata->num_rows > 0){
    $data = $qdata->fetch_assoc();
    echo $data['password'];
}

NEVER store passwords in plaintext. Also, your code is vulnerable to SQL injection attacks.

See:
https://www.php.net/manual/en/pdo.connections.php

https://www.php.net/manual/en/pdo.prepared-statements.php

9 Likes

Is the code you shared really the full code of your login.php file? I don’t see any code that would cause the error you see.

6 Likes

The rest is just the connecting database and the $user variable called… I tried inserting data and it worked but then this part is not working… So I put in forum… Let me try once more if not works I will say.

Please do note that the PHP error message tells you on which line in which file the error occurred.

It would be nice if we could just see what line that is, as opposed to having to guess it based on the error and the code.

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.