kcb Posted June 15, 2007 Share Posted June 15, 2007 Hello. Very new PHP programmer here. I have zero experiences with regexes, which is why I'm making this thread. I programmed a very simple blog scripts and when someone types anything with an apostophre, then when it's submitted it comes out with a backslash in front of it. Example: "You're funny" will return "You\'re funny" in my script. I have a feeling this is a regex issue, but am not sure. I tried looking through the PHP manual, but I'm not even sure what I'm looking at yet. I'm only half way through the Zend tutorial. Thanks in advance and sorry about the newbie question. Quote Link to comment https://forums.phpfreaks.com/topic/55684-solved-newbie-question-removing-the-from-my-blog-scripts/ Share on other sites More sharing options...
trq Posted June 15, 2007 Share Posted June 15, 2007 This is because you have magic quotes enabled in your configuration but it would also seem your are escaping your data manually using addslashes. Nothing to do with regex. Can we see the code where you insert this data to the database? Quote Link to comment https://forums.phpfreaks.com/topic/55684-solved-newbie-question-removing-the-from-my-blog-scripts/#findComment-275134 Share on other sites More sharing options...
kcb Posted June 15, 2007 Author Share Posted June 15, 2007 PHP file <html> <head> <title></title> </head> <body> <?php $input = $_POST['yourname']; echo $input."<br />"; ?> <?php $input = $_POST['subject']; echo $input."<br />"; ?> <?php if (is_array($_POST['blah'])) { echo "From the "; foreach ($_POST['blah'] as $i) { echo $i." department"; } echo "<br />"; } ?> <?php $input = $_POST['msg']; echo $input; ?> </body> </html> HTML file <html> <head> <title>K.C.'s Blog script</title> </head> <body> <form action="blog.php" method="post"> Name: <select name="yourname"> <option value="K.C. Brawley">K.C. Brawley <option value="Aaron Falanga">Aaron Falanga </select> <br /><br /> Subject: <input type="text" name="subject" size="45"><br /><br /> <input type="radio" name="blah[]" value="General News">General News <input type="radio" name="blah[]" value="Book Review">Book Review <input type="radio" name="blah[]" value="Ranting and Raving">Ranting and Raving <br /><br /> Message:<br /> <textarea cols="50" rows="4" name="msg"></textarea> <br /> <input type="submit" name="submit" value="Submit Blog"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/55684-solved-newbie-question-removing-the-from-my-blog-scripts/#findComment-275137 Share on other sites More sharing options...
trq Posted June 15, 2007 Share Posted June 15, 2007 Should be as simple as applying stripslashes prior to output. eg; <?php echo stripslashes($input)."<br />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/55684-solved-newbie-question-removing-the-from-my-blog-scripts/#findComment-275139 Share on other sites More sharing options...
kcb Posted June 15, 2007 Author Share Posted June 15, 2007 Should be as simple as applying stripslashes prior to output. eg; <?php echo stripslashes($input)."<br />"; ?> Geez, thanks man. I was trying to take a crash course in regexes and everything, and it turns out it's as simple as this.. Again, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/55684-solved-newbie-question-removing-the-from-my-blog-scripts/#findComment-275141 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.