php - PHP : Parse error: syntax error, unexpected T_STRING in C:\wamp\mysqli_connect.php on line 8

标签 php syntax-error

嗨,我正在尝试使用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() );

?>

最佳答案

在第一行,删除- mysqli_connect.php部分,因为那是无效的PHP。如果要包括它,请将第一行更改为<?php // mysqli_connect.php

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

关于php - PHP : Parse error: syntax error, unexpected T_STRING in C:\wamp\mysqli_connect.php on line 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5751072/

相关文章:

php - 在每次页面加载时自动索引、修复和优化 MySQL 表

phpexcel 将php内的数据整理

php - 为什么不能在 php 中正确使用 .htaccess ?

python - if 语句中的冒号语法错误

javascript - 为什么 AppleScript 无法实现 JavaScript 片段?

python - f 字符串给出 SyntaxError?

javascript - 如何使用 JavaScript 从 HTML 表格的单元格中获取值

php - 如何自定义 WordPress 中的 Subscribe2 按钮外观?

python - TypeError : calculations() missing 1 required positional argument: 'entries'

sql - PostgreSQL 驱动程序在某些 SQL 语句上附加隐藏字符