Jump to content

MySQL Database insert validation, and displaying info


mat3000000

Recommended Posts

Hi,

 

I have a website where users can log on and edit their profile pic, name, biography etc.

I was wondering about the correct way to:-

  • Add data to the database through forms (Register.php)
  • Display the data on a page

Using mysql escape sting, however, the way I am currently using will display a '\' before any ' symbol. So it's >> it\'s ...

 

Here is a snippet of the code I am using...

 

//insert data
$about1 = mysql_real_escape_string($_POST['about']);

//get
$query = mysql_query("SELECT * FROM `staff` WHERE username='$username'");
$row = mysql_fetch_array($query);
$about = $row['about'];
echo $about;

Link to comment
Share on other sites

The easiest solution would be to simply remove the slashes using PHP's stripslashes() function. However, as Pikachu pointed out, the problem most likely stems from a setting in your php.ini. It would be best if you turned this setting off, to avoid this problem in the future. Unfortunately, the text in your database already will be unaffected by this change. Is your server in development or production?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.