PHP:解析错误:语法错误,第 8 行 C:\wamp\mysqli_connect.php 中出现意外的 T_STRING
当我单击此网页中的“查看用户”链接时,出现此错误。如果有必要的话,我会发布更多代码。有问题的行以粗体显示。
<?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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的意思是
define('DB_USER', 'username');
吗?我认为应该删除
- mysqli_connect.php
。Did you mean
define('DB_USER', 'username');
?And I think that
- mysqli_connect.php
should be removed.在第一行中,删除
- 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