gpt4 book ai didi

php - MySql连接

转载 作者:太空宇宙 更新时间:2023-11-03 10:43:51 24 4
gpt4 key购买 nike

<分区>

    <?php
// connect to MySQL
$connect = new PDO ("localhost", "username", "")
or die ( "Hey loser, check your server connection");

// make sure we`re using the right database
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, 3)";
$results = mysql_query($insert)
or die (mysql_error());

// insert data into "movietype" table
$type = "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 Carrey', 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 (mysql_error());
echo "Data inserted succsesfully!";
?>

大家好。我有个问题。当我运行此代码时,出现此错误:

( ! ) Fatal error: Uncaught exception 'PDOException'

有消息

'invalid data source name' in C:\wamp\www\moviedata.php on line 3 ( ! ) PDOException: invalid data source name in C:\wamp\www\moviedata.php on line 3

如果有人能帮我解决这个问题,我将不胜感激。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com