hi guys.
first post! i've been learning php for 3 days and am a complete noob! i'm hoping to be able to learn a lot here and help others out too 🙂
i'm having a problem with this code:
<?php
//connect to mysql
$connect=mysql_connect("localhost", "user", "pass")
or die("hey, check ur connection");
//ak sure we're using the right databse
mysql_select_db("moviesite");
// insert data into "movie" table
$insert = "INSERT INTO movie (movie_id, movie_name, movie_type, "
"movie_year, movie_leadActor, movie_director) "
"VALUES (1, 'Bruce Almighty', 5, 2003, 1, 2), "
"(2, 'Office Space', 5, 1999, 5, 6), "
"(3, 'Grand Canyon', 2, 1991, 4, 31)";
$results=mysql_query($insert)
or die(mysql_error());
// insert data into "movieType" table
$insert ="INSERT INTO movieType (movieType_id, movieType_label) "
"VALUES (1, 'Sci Fi'), "
"(2, 'Drama'), "
"(3, 'Adventure'), "
"(4, 'War') "
"(5, 'Comedy'), "
"(6, 'Horror'), "
"(7, 'Action'), "
"(8, 'Kids'), "
$results=mysql_query($type);
or die(mysql_error());
//insert data into "people" table
$people = "INSERT INTO people (people_id, people_fullName, "
"people_isActor, people_isDirector) "
"VALUES (1, 'Jim Carey', 1, 0), "
"(2, 'Tom Shadyac', 0, 1), "
"(3, 'Lawrence Kasdan', 0, 1), "
"(4, 'Kevin Kline', 1, 0), "
"(5, 'Ron Livingston', 1, 0), "
"(6, 'Mike Judge', 0, 1)";
$results=mysql_query($people)
or die(mysq_error());
echo "data inserted successfully";
?>
i get an error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/filmsite/moviedata.php on line 9
if i comment out the section that tries to load data into movie table the same error shows up on line 18 - which makes me think there's problems on the lines that begin INSERT INTO
any ideas?
Thanks!