PHP:解析错误:语法错误,在C:\wamp\mysqli_connect中意外的T_STRING。php在8号线

时间:2021-08-20 22:46:30

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/

嗨,我正在尝试从http://www.larryullman.com/books/php-6和mysql-5的动态网站- - - visualquickpro -3 -edition/中获取一个基本的web页面。

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() );

?>

2 个解决方案

#1


1  

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.

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

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

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

#2


2  

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

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

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

我认为- mysqli_connect。php应该被删除。

#1


1  

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.

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

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

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

#2


2  

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

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

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

我认为- mysqli_connect。php应该被删除。