php - return (mysql_result(mysql_query("SELECT COUNT('ID') FROM 'users' WHERE 'username' = '$username'") , 0) == 1) ? true : false; -


function user_exists($username) {     $username = sanitize($username);     //query = ;     return (mysql_result(mysql_query("select count('id') 'users' 'username' = '$username'") , 0) == 1) ? true : false; } 

this code gives error:

warning: mysql_result() expects parameter 1 resource, boolean given in c:\users\james\desktop\container\xampp\htdocs\triiline1\login.php on line 23 

i've looked around , other questions fixing don't seem fix problem.

i confused end of line: ? true : false; got code phpacademy tutorial on youtube, , can't find documentation on anywhere. suspect may outdated?

in mysql, identifier quote character backtick " ` " (not single quote) stated here: http://dev.mysql.com/doc/refman/5.0/en/identifiers.html. please update query use ticks on table name , column names follows:

"select count(`id`) `users` `username` = '$username'" 

because query did not succeed, mysql_query returned false reason error. please have @ documentation mysql_query here http://php.net/manual/en/function.mysql-query.php , check "return values" section thoroughly.

also mention tutorial believe beginning learn php db development, in case better start learning either mysqli http://php.net/manual/en/book.mysqli.php or pdo http://php.net/manual/en/book.pdo.php mysql deprecated.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -