Hello,
I don’t quite understand few things, so I though it would be a good idea to ask for help here.
[php]$result = $db->query(“SELECT * from user WHERE username=’ ".$username.” ’ AND password = sha1(’ ".$password." ')");[/php]
It’s a part of some user registration code. In a book I’ve been reading, authors use ’ ".$variable." ’ when they want to check some database records with what a user entred, but why do they use it? I mean dots are used to join string values as far as I know and " quote symbol can be used in adding some HTML code like in the echo example:
[php]echo “Some text.”;[/php].
Single quote is a part of MySQL syntax, right?
Next one: I want to make sure I think right
[php]$query=“SELECT * from tablename WHERE “.$searching_method.” like '%”.$statement."%’ ";[/php]
The $statement variable is an input entered by a user searching for somthing, so % at the begining means that the input he/she entered can be the beginning of some value the user wants to get, and at the end means that it can end with that value too, do I think right?
Another question
I created a MySQL database with a table called authorization and a column called id with all those needed things set (like Primary Key etc.), but if I want to add a new username the only way to avoid “adding” a new record to that column is to specify the right columns where I want to save username, password, email etc or does it go by and leave the id column as it is - and then add the value to the second column, which could be for instance username?
Well, if I face any other problem I’ll probably post it here
Thank you in advance!