HELP! update content even with a dash

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
buknoii
Forum Newbie
Posts: 4
Joined: Fri Mar 14, 2008 5:49 am

HELP! update content even with a dash

Post by buknoii »

hi there! i've created a php website and everytime i update it, it doesnt update if the data has '

below is my sample code :

Code: Select all

 
[color=#800000]<?php
$content_num_x = $_POST['frm_content_num'];
$content_heading_x = $_POST['frm_content_heading'];
 
mysql_query("UPDATE listings SET content_heading='$content_heading_x' WHERE content_num ='$content_num_x' ");
 
echo "<br><br>";
echo "<div align=center><h1>content updated</h1></div>";
 
mysql_close($con);
?>[/color]
 
and also why is it that data that i added ' shows with \ for example [b]season\'s should be season's [/b]
 
any help would be useful :)
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Re: HELP! update content even with a dash

Post by pcoder »

Use mysql_real_escape_string() function before passing the post content to the query.
8)
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: HELP! update content even with a dash

Post by infolock »

buknoii wrote:hi there! i've created a php website and everytime i update it, it doesnt update if the data has '

below is my sample code :

Code: Select all

 
[color=#800000]<?php
$content_num_x = $_POST['frm_content_num'];
$content_heading_x = $_POST['frm_content_heading'];
 
mysql_query("UPDATE listings SET content_heading='$content_heading_x' WHERE content_num ='$content_num_x' ");
 
echo "<br><br>";
echo "<div align=center><h1>content updated</h1></div>";
 
mysql_close($con);
?>[/color]
 
and also why is it that data that i added ' shows with \ for example [b]season\'s should be season's [/b]
 
any help would be useful :)

If it's adding a backspace(\) to apostrophe's automatically without you doing it, it's because you have magic_quotes turned on in your php.ini file.
Post Reply