How to copy record from mysql that contains HTML code ?

Hi!

Have a record in mysql database, that contains a field than hav HTML in it.
I want to copy this record to a new record like:

	$newsletter_data = $newsletter->get_newsletter($db,$newsletter_id);
	    
		session_start();
		$golfclub_id=(int)$_SESSION['logoclub'];
		$creatdate = date("Y-m-d");
		$template =  $newsletter_data['template'];
		$subj = $newsletter_data['subject'];
		$fromname = $newsletter_data['from_name'];
		$fromemail = $newsletter_data['from_email'];
		$content = .mysql_real_escape_string(($newsletter_data['content']).;
		$bounceemail = $newsletter_data['bounce_email'];
		
		
		$sql = "INSERT INTO `"._DB_PREFIX."newsletter` SET create_date='$creatdate', golf_id=$golfclub_id, template='$template', subject='$subj', from_name='$fromname', from_email='$fromemail', content='$content', bounce_email='$bounceemail'";
		        $res = query($sql,$db);
		        $newsletter_id = mysql_insert_id($db);

Open in new window


The field that have HTML tekst is -> $content

How can i solve this ?
Tryed this to:

$content = $newsletter_data['content'];

Open in new window

LVL 2
team2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Your code set looks almost right to me, but you want to use the INSERT syntax.  The existing query uses the UPDATE syntax.

Wrong ->> https://dev.mysql.com/doc/refman/5.7/en/update.html
Right ->> http://dev.mysql.com/doc/refman/5.7/en/insert.html

You will also want to get off MySQL as soon as possible.  Choose MySQLi or PDO.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0
team2005Author Commented:
Hi!

Have tested the same code, and just set :
$content = "Test";

And the record is created
0
Julian HansenCommented:
If you are getting this data from an existing record then you can combine an INSERT and a SELECT like this

$sql = "INSERT INTO `"._DB_PREFIX."newsletter` (
      create_date, 
      golf_id, 
      template, 
      subject, 
      from_name, 
      from_email, 
      content, 
      bounce_email)
    SELECT 
      NOW(), 
      golf_id, 
      template, 
      subject, 
      from_name, 
      from_email, 
      content, 
      bounce_email
  FROM `"._DB_PREFIX."newsletter` WHERE newsletter_id ='{$$newsletter_id}'";

Open in new window

As a further enhancement I would change the definition of the create_date field to a timestamp field and default it to CURRENT_TIMESTAMP so you don't have to specify it in the query.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
team2005Author Commented:
Thanks :)
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.