PHP:解析错误:语法错误,第 8 行 C:\wamp\mysqli_connect.php 中出现意外的 T_STRING

发布于 2024-11-02 22:54:07 字数 871 浏览 9 评论 0原文

您好,我正在尝试使用 http://www.larryullman.com/books/php-6-and-mysql-5-for-dynamic-web-sites-visual-quickpro-guide-3rd-edition/

当我单击此网页中的“查看用户”链接时,出现此错误。如果有必要的话,我会发布更多代码。有问题的行以粗体显示。

<?php - mysqli_connect.php

// This file contains the database access information. 
// This file also establishes a connection to MySQL 
// and selects the database.

// Set the database access information as constants:
**DEFINE ('DB_USER', 'username');**
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');

// Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' .mysqli_connect_error() );

?>

Hi I am trying to get a basic web page using code from http://www.larryullman.com/books/php-6-and-mysql-5-for-dynamic-web-sites-visual-quickpro-guide-3rd-edition/

I am getting this error when I click on the "View User's" link in this webpage. There is more code which I will post if necessary although. The line in question is bolded.

<?php - mysqli_connect.php

// This file contains the database access information. 
// This file also establishes a connection to MySQL 
// and selects the database.

// Set the database access information as constants:
**DEFINE ('DB_USER', 'username');**
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');

// Make the connection:
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' .mysqli_connect_error() );

?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不羁少年 2024-11-09 22:54:07

您的意思是 define('DB_USER', 'username'); 吗?

我认为应该删除 - mysqli_connect.php

Did you mean define('DB_USER', 'username'); ?

And I think that - mysqli_connect.php should be removed.

心病无药医 2024-11-09 22:54:07

在第一行中,删除 - mysqli_connect.php 部分,因为它不是有效的 PHP。如果要包含它,请将第一行更改为

编辑:我更正了我的帖子,因为我最初的想法是完全错误的

On the first line, remove the - mysqli_connect.php part because that is not valid PHP. If you want to include it, change the first line to <?php // mysqli_connect.php.

EDIT: I corrected my post because my initial thought was completely wrong

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文