我一直盯着這個錯誤已經有一個多小時了,而且我不能爲了我的生活看到什麼是錯的。解析錯誤我找不出
這裏是我的錯誤:
解析錯誤:語法錯誤,意外 '(' 在C:\網絡\ account.php上線42
這裏是我的代碼(Line42始於「$搜索字符串「)後的HTML中的第一個PHP的標籤。
<?php
include_once 'header.php';
include_once 'functions.php';
require_once 'login_users.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to database:" . mysql_error());
mysql_select_db($db_database)
or die("Unable to find database:" . mysql_error());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Weapon Build Creator</title>
<link href="styles/main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.auto-style1 {
margin-top: 0px;
}
</style>
</head>
<body style="background-image: url('images/bg.jpg')">
<div id="form" style="left: 50%">
<div class="newsdiv">
<br />
<p class="title">MY BUILDS</p>
<?php //search result table
$searchstring = "SELECT buildname,weapon,category,id,author,buildname FROM weapons WHERE author="($_SESSION['username'])" "; // Line 42
$result = mysql_query($searchstring);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
.... More code down here
讓我知道如果你能看到它!
由於一噸!
什麼是第42行?清楚地標記它。 –
@SteelyDan - 你有很多答案。你真的應該把答案標記爲接受:-) – bestprogrammerintheworld
沒有人說過它,所以我添加了強制性的:在php中的mysql函數是[棄用](http://php.net/manual/en/function。 mysql-db-query.php),請使用[MySqli](http://www.php.net/manual/en/book.mysqli.php)或[PDO](http://www.php.net/手冊/ en/ref.pdo-mysql.php)。並請使用[參數化查詢](http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php)。爲了您自己的安全。 – Whistletoe