Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,801 members, 7,810,086 topics. Date: Friday, 26 April 2024 at 08:25 PM |
Nairaland Forum / Science/Technology / Webmasters / Php Developers Help Me Resolve This (759 Views)
Gurus Pls Help Me Resolve My Fiverr Withdrawal Issues / Easyphp (swamp Server) Refuses To Start Pls Help Me Resolve This / Pls Help Resolve This Codes Issue (2) (3) (4)
Php Developers Help Me Resolve This by winexviv: 6:02pm On May 28, 2013 |
Please what could possibly be wrong with this function. I've been constantly getting this error "Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='' AND password='' LIMIT 1' at line 1". Your kind comments will be of great assistance.
|
Re: Php Developers Help Me Resolve This by spikesC(m): 7:00pm On May 28, 2013 |
From the error; '='username_is_supposed_to_be_here' AND password='password_is_supposed_to_be_here' LIMIT 1' at line 1" So check whether you're actually substituting the variables |
Re: Php Developers Help Me Resolve This by Nobody: 10:42pm On May 28, 2013 |
SORRY I AM NOT AN OOP EXPECT. BUT THIS WILL SOLVE THE ISSUE. =================================================================================== function authenticate($username,$password){ ===================================================================================
NOTE: I HOPE YOU UNDERSTAND THAT YOU HAVE TO SANITIZE YOUR INPUT AND ALSO PROTECT YOUR OUTPUT AGAINST XSS ATTACK |
Re: Php Developers Help Me Resolve This by Nobody: 11:15pm On May 28, 2013 |
OOP APPROACH public static function authenticate($username="", $password="" ) { global $database; $username = $database->escape_value($username); $password = $database->escape_value($password); $result_array = self::find_by_sql("SELECT * FROM users WHERE username='{$username}' AND password='{$password}' LIMIT 1" ); return !empty($result_array) ? array_shift($result_array) : false; } NOTE: THIS IS NOT THE BEST WAY TO VERIFY USERNAME AND PASSWORD. I CAN SEE YOU ARE DOING THIS BECAUSE YOU ARE STORING THE PASSWORD IN PLAIN TEXT OR YOU HASH THE PASSWORD BUT DO NOT USE A SALT. |
(1) (Reply)
Whot! Game For Android Phones / Php Codes For Moving Text And Rolling Banners / My Javascript Code Is Not Working
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13 |