Thread: PHP mysql error
View Single Post
Old 09-03-2012, 03:29 PM   PM User | #23
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,658
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by tangoforce View Post
Should be this:

"SELECT id, email, key FROM friendko_text WHERE key = '$_POST[key]'";
Quote:
Originally Posted by Fou-Lu View Post
That should work, and even without error if I'm not mistaken.
But I don't like that. The 'key' in my eyes is now a constant which should be a string.
What I mean is to do as:
PHP Code:
$query "SELECT id, email, key FROM friendko_text WHERE key = {$_POST['key']}";
// or
$query "SELECT id, email, key FROM friendko_text WHERE key = " $_POST['key']; 
Having looked at this post again, the only way 'key' could become a constant in my example string is if you're thinking that my double quotes were just used to quote a string and not to show the quotes as part of the code. I did however leave a semicolon there to show that it should be seen as code.

I would like to clarify that my double quotes were supposed to be included as part of the code and NOT just to show the SQL itself. I should have used php code tags but I was in a rush.
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote