phpnewby1918 Posted January 25, 2011 Share Posted January 25, 2011 hi i'm trying to insert this text just "we're pleased to announce etc........ect" but I can only insert "We" i believe its because single quotation mark. I've tried using addslashes, mysqli_real_escape_string and htmlspecialchars, strp_tags and applied it to my variable $s. But what ever i seem to try and insert still results in "we" being inserted. Cant see for the life of me why??? appreciate any help if (isset($_POST['submitted'])) { $errors = array(); if (empty($_POST['title'])) { $errors[] = '<p class="error">Either you haven\'t filled in the title or story for this news</p>'; } else { $t = mysqli_real_escape_string($dbc, $_POST['title']); } if (empty($_POST['story'])) { $errors[] = '<p class="error">Either you haven\'t filled in the title or story for this news</p>'; } else { $s = $_POST['story']; } echo $s; if(empty($errors)) { // No errors $q = "INSERT INTO news (title, story, date_added) values ('$t', '$s', NOW() )"; $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); if (mysqli_affected_rows == !1) { // It didnt run ok $errors[] = '<p class="error">An error occured with your upload<a href="loggedin.php"> Admin</a></p>'; } else { echo 'Your news story has been added, visit <a href="news.php">News</a>'; } //if mysqli_affected rows } else { echo '<p class="error">The following errors occured<br />'; foreach ($errors as $msg) { echo " - $msg<br>"; } echo 'Please try again'; } // end of $errors } // End of submitted This is my code i'm using :-) as you an see i'm posting the variable $s which is ($_POST['story'] with no functions and it still only inserts "we" nothing more????? Link to comment https://forums.phpfreaks.com/topic/225673-inserting-into-db/ Share on other sites More sharing options...
BlueSkyIS Posted January 25, 2011 Share Posted January 25, 2011 if (get_magic_quotes_gpc()) { $s = stripslashes($s); } $s = mysqli_real_escape_string($dbc, $s); Link to comment https://forums.phpfreaks.com/topic/225673-inserting-into-db/#findComment-1165234 Share on other sites More sharing options...
phpnewby1918 Posted January 25, 2011 Author Share Posted January 25, 2011 Looking more into it i type ' into word and it doesnt create a ' it creates a curly single quotation mark. So when i copy if from word into my upload section it treats it as a different charachter to ' adn then the query fails. but i've just gone and chantged the Word instances of the single quotation mark to my keyboard ' single quotation mark and the string inserts all the way up until the next occurance of the word single quotation mark.???? Any ideas? Link to comment https://forums.phpfreaks.com/topic/225673-inserting-into-db/#findComment-1165238 Share on other sites More sharing options...
BlueSkyIS Posted January 25, 2011 Share Posted January 25, 2011 did you try the code i posted? Link to comment https://forums.phpfreaks.com/topic/225673-inserting-into-db/#findComment-1165245 Share on other sites More sharing options...
Mr Hyde Posted January 25, 2011 Share Posted January 25, 2011 Looking more into it i type ' into word and it doesnt create a ' it creates a curly single quotation mark. So when i copy if from word into my upload section it treats it as a different charachter to ' adn then the query fails. but i've just gone and chantged the Word instances of the single quotation mark to my keyboard ' single quotation mark and the string inserts all the way up until the next occurance of the word single quotation mark.???? Any ideas? Definitely check to make sure magic quotes aren't on like BlueSky mentioned.... and NEVER EVER EVER EVER use word as an editor. It inserts all kinds of random characters that screw things up that you often can't even see. Word is not a code editor. At least use notepad instead. Link to comment https://forums.phpfreaks.com/topic/225673-inserting-into-db/#findComment-1165249 Share on other sites More sharing options...
phpnewby1918 Posted January 25, 2011 Author Share Posted January 25, 2011 Yeah, I did, it does appear like i have them on. But it still wouldnt work. If i free type in my page using ' or " its fine and inserts fine. Its just when i type in Word it changes ' to some similar but differnet symbol and then it just wont go in?? Link to comment https://forums.phpfreaks.com/topic/225673-inserting-into-db/#findComment-1165252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.