Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: mysql_result() expects parameter 1 to be resource, boolean given

Tags:

sql

php

i know that we already had a lot of question about this error, but i can not fix my code, so anyone here please help me fix this problem. my code like this

function login($username, $password) {
    $user_id = user_id_from_username($username);

    $username = sanitize ($username);
    $password = md5 ($password);

    return (mysql_result(mysql_query("SELECT COUNT (`user_id`) FROM `users` 
        WHERE `username` = '$username' AND `password` = '$password'"),0)==1) ? $user_id : false;

i am looking forward to hear from you guys. i am a new member on this so please keep your answer as simple as possible. thank you.

like image 647
Hoàng Trung Hiếu Avatar asked Nov 21 '22 22:11

Hoàng Trung Hiếu


1 Answers

I think that this problem is occured because : You write mysql every where. Instead Of that write it mysqli every where. If till now also the problem is not resolved. Let me know I will tell another method to fix this issue.

like image 139
Tejaswa Avatar answered May 27 '23 11:05

Tejaswa