Hey guys, been working with some PHP lately, and I have ran into a problem with one of my functions. I believe it has something to do with my query, but im not sure.
You need to add the "$" before "f_password" in the SQL query, and there is no semi-colon at the end. That should make the query valid, provided the input to the function is good and your database is setup properly.
Variables values will still be substituted in strings created with double quotes ("). Also, in SQL queries, the names of databases, tables and columns do not go in quotes, they stay as they are.
Get the errors:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\OnlineDocuments\func\functions.php on line 23
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\OnlineDocuments\func\functions.php on line 24
On a sidenote, I cannot see what you are doing with the $f_email and $f_password variables outside of this function, but if you pass them straight from the user input, this code is vulnerable to SQL injection. This means a malicious attacker could retrieve, delete, or modify anything in your database.
Either escape the output with mysql_real_escape_string(); or, if you are serious about PHP, learn to use PDO (PHP Data Objects), offering you an object oriented way to access databases and eliminating the possibility of SQL injection when used properly.