0

can someone please help, i have a text area form that users can type in content to and submit it and then the content gets stored in mysql table.

The problem i am having is that whenever a user types an apostrophe ' this is inserted with a / and i want to get rid of the /.

my column is utf8_general_ci format (long text) am i even using the right type of format here?

also here's my code maybe i need to put something in the mysql?

please can someone show me where im going wrong thank you.

html form:

<form action="includes/changebio.php" method="post" id="form1">         
 <textarea id="bio" style="width: 448px; 
    margin-top:3px;
    text-align:left;
    margin-left:-2px;
    height: 120px;
    resize: none; 
    border: hidden;" textarea name="bio" data-id="bio" maxlength="710"><?php echo htmlspecialchars($profile['bio']); ?></textarea>
<input type="image" src="assets/img/icons/save-edit.png"class="bio-submit" name="submit" value="submit" id="submit"/>
</form>

mysql:

<?php ob_start(); ?>
<?php
require_once("session.php"); 
require_once("functions.php");
require('_config/connection.php');
?>
<?php 
session_start();
include '_config/connection.php'; 
$bio = $_POST['bio'];
$result = mysql_query("SELECT bio FROM ptb_profiles WHERE id=".$_SESSION['user_id']."");
if(!$result) 
{ 
echo "The username you entered does not exist"; 
} 
else 
if($bio!= mysql_result($result, 0)) 
{ 
echo ""; 
    $sql=mysql_query("UPDATE ptb_profiles SET bio ='".mysql_real_escape_string($bio)."' WHERE id=".$_SESSION['user_id'].""); 
}
header("Location: {$_SERVER['HTTP_REFERER']}");
?>
<?php ob_end_flush() ?>
John James
  • 31
  • 4
  • 7
  • 1
    You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). – Quentin Feb 16 '13 at 18:00

1 Answers1

1

There are 2 possible cases

  1. You have magic quotes on. Turn them off.
  2. Some sort of Sanitize Them All function run on all your input data. Get rid of it.
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345