westes
08-14-2008, 12:41 AM
$sql = "SELECT * FROM 'users' WHERE 'username'='{$username}'";
Im not sure because im getting errors from this
Im not sure because im getting errors from this
|
||||
Is this correct syntax?westes 08-14-2008, 12:41 AM $sql = "SELECT * FROM 'users' WHERE 'username'='{$username}'"; Im not sure because im getting errors from this oesxyl 08-14-2008, 01:08 AM $sql = "SELECT * FROM 'users' WHERE 'username'='{$username}'"; Im not sure because im getting errors from this what errors? post the message. regards westes 08-14-2008, 01:38 AM The code above oesxyl 08-14-2008, 02:09 AM The code above the code above is the query not the error message. You said that give you errors. What errors? regards rangana 08-14-2008, 05:44 AM I should say that I'm in the process of learning mySQL and PHP. Though I might be at mistake, but I believe the syntax is erroneous, and should have been: $sql = "SELECT * FROM 'users' WHERE 'username'='".$username."'"; oesxyl 08-14-2008, 05:54 AM I should say that I'm in the process of learning mySQL and PHP. Though I might be at mistake, but I believe the syntax is erroneous, and should have been: $sql = "SELECT * FROM 'users' WHERE 'username'='".$username."'"; if {} is the problem, php can use curly syntax, :) http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex I guess op must say what is his problem if want help, :) regards Fou-Lu 08-14-2008, 08:06 AM Thats right. {} can be wrapped around variables within strings, thought you'll likely use it more for array indices within double quoted text. Are you actually executing this query? This is just a string representation of you're query, you need to run it though a mysql_query or whatever database querying function you are using to create a resultset for it. Once you have a resultset you can retrieve records with mysql_fetch_[row/assoc/array/object] methods. I assumed mysql, but you may be using mysqli or mssql or whatever. They are all pretty similar to use. Oh, just as a side note. I always write my queries either like how you have it rangana, or using sprintf or prepared statements. Just a habit I got into I suppose :P the-dream 08-14-2008, 02:37 PM Try: $sql = "SELECT * FROM `users` WHERE username = '".$username."'"; dumpfi 08-14-2008, 05:45 PM If you want to quote fields and table names use the backquote, e.g. `users`. This is typically only necessary if these names are reserved for SQL syntax (for example if you have a field named "order", though some DBs handle even these names just fine). Values, however, must be quoted using either single or double quotes, e.g. "my value". It is unnecessary to enclose integers in quotes (but it doesn't hurt either). dumpfi |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum