Heredoc插入数据

时间:2015-05-13 10:52:38

标签: php html mysql

我无法创建属于现有数据库的表以便连接它们。在代码中我使用heredoc语法,以便在应该创建的表中插入元素

<?php error_reporting(E_ALL); ini_set('display_errors', 1);?>
<?php 
    $db = mysql_connect('localhost', 'pippo', 'pluto') or
	    die ('Unable to connect. Check your connection parameters'.);
	mysql_select_db('moviesite', $db) or die(mysql_error($db));
	
	//crea la tabella reviews
	$query = 'CREATE TABLE reviews (
	        review_movie_id  INTEGER UNSIGNED NOT NULL,
			review_date      DATE             NOT NULL,
			reviewer_name     VARCHAR(255)     NOT NULL,
			review_comment   VARCHAR(255)     NOT NULL,
			review_rating    TINYINT UNSIGNED NOT NULL  DEFAULT 0,
			KEY  (review_movie_id)
			)
			ENGINE=MyISAM';
	mysql_query($query, $db) or die (mysql_error($db));
	
	//inserisce i nuovi dati nella tabella reviews
	$query = <<<ENDSQL
    INSERT INTO reviews
	    (review_movie_id, review_date, reviewer_name, review_comment,
		     review_rating)
	VALUES
	    (1, "2008-09-23", "Jhon Doe", "I thought this was a great movie
		     Even though my girlfriend made me see it against my will.", 4),
		(1, "2008-09-23", "Billy Bob", "I liked Eraserhead better.", 2),
		(1, "2008-09-28", "Peppermint Pappy", "I wish I'd have seen it
		     sooner!", 5),
		(2, "2008-09-23", "Marvin Martian", "This is my favorite movie. I 
		     didn't wear my flair to the movie but I loved it anyway.", 5),
		(3, "2008-09-23", "George B.", "I liked this movie, even though I
		     Thought it was an informational video from my travel agent.", 3)
ENDSQL;
mysql_query($query, $db) or die(mysql_error($db));

echo 'Moviesite successfully updated!';
?>	

我还添加了错误报告,但它根本没有报告!请帮我解决这个问题。服务器返回的唯一内容是500错误

0 个答案:

没有答案