TRI0N Posted April 14, 2008 Share Posted April 14, 2008 Okay tried to search on this but how do I deal with Hyphen or Quotes in input fields? Right now if I put in Event: Mike's Party It will cause data entry problem. Link to comment https://forums.phpfreaks.com/topic/101123-solved-php-amp-mysql-use-of-hyphenquotes-in-data/ Share on other sites More sharing options...
gluck Posted April 14, 2008 Share Posted April 14, 2008 use this mysql_real_escape_string() Link to comment https://forums.phpfreaks.com/topic/101123-solved-php-amp-mysql-use-of-hyphenquotes-in-data/#findComment-517190 Share on other sites More sharing options...
TRI0N Posted April 15, 2008 Author Share Posted April 15, 2008 So I'm taking that the following will work then? mysql_query("INSERT INTO clients VALUES('NULL','$client_id','$l_name','$f_name','mysql_real_escape_string($event_name)')") OR die(mysql_error()); This will allow the correct input of a form for Event Name to be placed into the MySQL data field with the value of: Mike's Party Rather then: Mike MySQL Error? Thanks I will give it a shot. Link to comment https://forums.phpfreaks.com/topic/101123-solved-php-amp-mysql-use-of-hyphenquotes-in-data/#findComment-517268 Share on other sites More sharing options...
atl_andy Posted April 15, 2008 Share Posted April 15, 2008 I think you'll need to read up on the syntax of mysql_real_escape_string. It's what you need, but not how you have it. Link to comment https://forums.phpfreaks.com/topic/101123-solved-php-amp-mysql-use-of-hyphenquotes-in-data/#findComment-517327 Share on other sites More sharing options...
fenway Posted April 15, 2008 Share Posted April 15, 2008 So I'm taking that the following will work then? mysql_query("INSERT INTO clients VALUES('NULL','$client_id','$l_name','$f_name','mysql_real_escape_string($event_name)')") OR die(mysql_error()); This will allow the correct input of a form for Event Name to be placed into the MySQL data field with the value of: Mike's Party Rather then: Mike MySQL Error? Thanks I will give it a shot. It's a PHP function... you can't pass it to mysql. Link to comment https://forums.phpfreaks.com/topic/101123-solved-php-amp-mysql-use-of-hyphenquotes-in-data/#findComment-517661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.