Link to home
Start Free TrialLog in
Avatar of team2005
team2005

asked on

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

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

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.
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
Avatar of team2005
team2005

ASKER

Hi!

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

And the record is created
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks :)
You are welcome.