phpcoder981 Posted January 2, 2011 Share Posted January 2, 2011 Shouldn't INSERT INTO `users` (`email`,`password`,`date_of_birth`) VALUES('$EMAIL','xx''xx''xx','$DOB_FULL') Error out because of the 'xx''xx''xx' I'm confused... it puts xx'xx'xx in the password field Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/ Share on other sites More sharing options...
Pikachu2000 Posted January 2, 2011 Share Posted January 2, 2011 Since there aren't any commas separating them, everything between the first and last quote is read as one value. Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153761 Share on other sites More sharing options...
phpcoder981 Posted January 2, 2011 Author Share Posted January 2, 2011 Then why does it display: xx'xx'xx instead of xx''xx''xx Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153763 Share on other sites More sharing options...
Anti-Moronic Posted January 2, 2011 Share Posted January 2, 2011 Either way, this is just a badly constructed sql query. Why are you using single quotes within single quotes in this instance? What do you want the output to be? These should really be escaped: 'xx''xx''xx' VALUES('$EMAIL','xx\'\'xx\'\'xx','$DOB_FULL') Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153767 Share on other sites More sharing options...
phpcoder981 Posted January 2, 2011 Author Share Posted January 2, 2011 I know they should be, and I know this is a bad string. I'm trying to find out how it is behaving, its just bugging me. Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153768 Share on other sites More sharing options...
PFMaBiSmAd Posted January 2, 2011 Share Posted January 2, 2011 From the mysql documentation (Literal values/Strings)- Quoted strings placed next to each other are concatenated to a single string. The following lines are equivalent: 'a string' 'a' ' ' 'string' Edit: And double single-quotes are treated as a literal single-quote in a string, depending on what and where you are doing this. Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153769 Share on other sites More sharing options...
revraz Posted January 2, 2011 Share Posted January 2, 2011 Actually, it should be hashed and not escaped, since it's a PW. Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153773 Share on other sites More sharing options...
phpcoder981 Posted January 2, 2011 Author Share Posted January 2, 2011 Thanks everyone, I learned how it works. Special thanks to PFMaBiSmAd for explaining where he got his information. After reading it, I understood everything. Quote Link to comment https://forums.phpfreaks.com/topic/223177-query/#findComment-1153777 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.