Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:33:10+00:00 2026-06-11T05:33:10+00:00

I’d like to store some div content when a button is pressed. I need/want

  • 0

I’d like to store some div content when a button is pressed. I need/want to save the html tags as well in order to reuse.

When I replace the post variables by any type of string, it works flawlessly. I tried cleaning the html variable from line breaks but it didn’t do it, tried also to shell the $HTML post in a $var = <<<HTML HTML, but this didn’t work either.

Here is the javascript :

$("#save").click(function(){
var pageHTML = $("#page_wrap").html();
var name_page = "name";
jQuery.ajax({
  type: "POST",
  url: "php/saveModel.php",
  data: {   nHTML: pageHTML,
            page : name_page
        },
    success:function(data){
      var responseData = jQuery.parseJSON(data);
      var new_div = responseData.message;
      $("#page_wrap > *").remove();
      $("#page_wrap").prepend(new_div);
      $('.editable').aloha();
    }
})
})

And here is the php :

<?php

mysql_connect('localhost','name','pwd');  
mysql_select_db('db');
mysql_query("SET NAMES 'utf8'");

$id = $_POST['page'];
$HTMLpost = $_POST['nHTML'];

$insertSignup = mysql_query("UPDATE Table_name SET model_test='$HTMLpost' WHERE    identifiant='$id'");

if($insertSignup){ 
$status = "success";
$message = "OK";
}
else {
$status = "error";
$message = "NOT OK";
}

//return json response
$data = array(
    'status' => $status,
    'message' => $message
);

echo json_encode($data);
exit;
?>

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:33:10+00:00Added an answer on June 11, 2026 at 5:33 am

    Simple answer: use mysql_real_escape_string() to change the quotes to make it safe for entry into the database.

    $HTMLpost = mysql_real_escape_string($_POST['nHTML']);
    $insertSignup = mysql_query("UPDATE Table_name SET model_test='$HTMLpost' WHERE    identifiant='$id'");
    

    Longer answer: You should not be using the mysql_() functions as they are being depreciated. Check out prepared statements with PDO or mysqli instead – they will safely handle this for you (and they are not being depreciated).

    Reading: http://php.net/manual/en/pdo.prepared-statements.php or google for more – plenty of examples around. Best to learn now before you get stung when the mysql_() functions do get removed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I would like to count the length of a string with PHP. The string
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.