Jump to content

inserting large text chunks into database


pouncer

Recommended Posts

Basically, I give my users a massive text area in their profile section to write their interests and stuff. My question is how exactly should i insert it into my database because i have to deal with escape chars or whatever??

$Interests = stripslashes($_POST['txt_Interests']);
$profile = mysql_query("UPDATE user_profile SET Interests = '$Interests' WHERE user_id = '$user_id'");

but i think it's giving errors on insert if i put escape chars in my interests etc, can someone please show me correct way off adding it to database?
Link to comment
Share on other sites

ok i have problems

[code=php:0]
if (isset($_POST['Save_Profile'])) {
$user_id = $_SESSION['UserID'];

$Status = stripslashes($_POST['sel_Status']);
$Forename = stripslashes($_POST['txt_Name']);
$Surname = stripslashes($_POST['txt_Surname']);
$Age = stripslashes($_POST['txt_Age']);
$Gender = stripslashes($_POST['sel_Gender']);
$Location = stripslashes($_POST['txt_Location']);
$Marital_Status = stripslashes($_POST['sel_MS']);
$Occupation = stripslashes($_POST['txt_Occupation']);
$AboutMe = stripslashes($_POST['txt_AboutMe']);
$Interests = mysql_escape_string($_POST['txt_Interests']);
$Quotes = stripslashes($_POST['txt_Quotes']);

$profile = mysql_query("UPDATE user_profile SET
Profile_Status = '$Status',
Forename = '$Forename',
Surname = '$Surname',
Age = '$Age',
Gender = '$Gender',
Location = '$Location',
Marital_Status = '$Marital_Status',
Occupation = '$Occupation',
About_Me = '$AboutMe',
Interests = '$Interests',
Fav_Quotes = '$Quotes'
WHERE user_id = '$user_id'
") or die (mysql_error());

if ($profile) {
echo "Your profile has been saved, please wait 2 seconds.";
echo "<meta http-equiv=\"refresh\" content=\"2; url=myprofile.php\" />";
}
}
[/code]

If i put in my interests:

Hello what's up

i get this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's up', Interests = '', Fav_Quotes = ''

i'm guessing its the word: what's and the ' is clashing
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.