Jump to content

unable to handle few character..


monika

Recommended Posts

The below is the announcement php code..

this code fails to handle diffrent character like [']

when ever i type monika's and click send button to dump in mysql it does not do.

It does not recoz other simillar charcter too..

Could any one pls help me for this...

 

----------

<?php include ("config.php");  ?>

 

<?php
if((isset($act)) && ($act=="action")){
$dates=date("Y-m-d");
echo "<div class=text>Data successfully updated on ". $dates. "<br> please wait while your browser redirects you to the main admin page.....</div>";

$sql=mysql_query("update announcement set date='$dates', title='$announce1', text='$detail1', title1='$announce2', text1='$detail2', title2='$announce3', text2='$detail3'");

?>
<script language="javascript">
setTimeout('test()',2000);
function test(){
window.location.href="../index.php"
}
</script>
<?php
}else{
echo 'You are not allowed here';
?>
<script language="javascript">
setTimeout('test()',1500);
function test(){
window.location.href="index.php"
}
</script>
<?php } ?>

Link to comment
https://forums.phpfreaks.com/topic/60889-unable-to-handle-few-character/
Share on other sites

// Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON

if(get_magic_quotes_gpc()) {

            $detail1        = stripslashes($_POST['text']);

            $announce2 = stripslashes($_POST['title1']);

        } else {

            $detail1        = $_POST['text'];

            $announce2 = $_POST['title1'];

        }

if(get_magic_quotes_gpc()) {

$detail2        = stripslashes($_POST['text1']);

            $announce3 = stripslashes($_POST['title2']);

        } else {

            $detail2        = $_POST['text1'];

            $announce3 = $_POST['title12'];

        }

if(get_magic_quotes_gpc()) {

$detail3        = stripslashes($_POST['text2']);

            $announce4 = stripslashes($_POST['title3']);

        } else {

            $detail3        = $_POST['text2'];

            $announce4 = $_POST['title3'];

        }

 

 

// is that ok..  i dont knw..

Don't use the magic quotes, they do no good. Especially since they are being depreciated.

 

<?php
if((isset($act)) && ($act=="action")){
$dates=date("Y-m-d");
echo "<div class=text>Data successfully updated on ". $dates. "<br> please wait while your browser redirects you to the main admin page.....</div>";

$sql=mysql_query("update announcement set date='$dates', title='" . mysql_real_escape_string($announce1) . "', text='" . mysql_real_escape_string($detail1) . "', title1='" . mysql_real_escape_string($announce2) . "', text1='" . mysql_real_escape_string($detail2) . "', title2='" . mysql_real_escape_string($announce3) . "', text2='" . mysql_real_escape_string($detail3) . "'");

?>
<script language="javascript">
setTimeout('test()',2000);
function test(){
window.location.href="../index.php"
}
</script>
<?php
}else{
echo 'You are not allowed here';
?>
<script language="javascript">
setTimeout('test()',1500);
function test(){
window.location.href="index.php"
}
</script>
<?php } ?>

 

That should solve your problem. The first post referenced the right function.

 

www.php.net/mysql_real_escape_string

 

I suggest you read up on it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.