これは、不動産リスティングのデータベースにリスティングを提出するための簡単なフォームです。これはこれまで私が初めて行ったことなので、私がやっていることに気付いたら、それは悪い練習か、まったくばかげたことです。私に知らせてください。とにかく構文解析エラー:構文エラー、予期しないT_IF、 '、'または ';'
、私は取得していますエラーへ上:
Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in C:\Program Files\EasyPHP-5.3.9\www\addform.php on line 62
私はセミコロンが欠落しているすべての行が表示されない、そしてライン62はif文です....については、このエラーは何ですか?
<?php
//set database login variables
require_once 'login.php';
//connect to server
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
//all server access lines have to be dealt with better than this. See page 227. Probably create a function.
//Note to self: look into try/catch in php
if (!$db_server) die("Unable to connect to database: " . msql_error());
mysql_select_db($db_database, $db_server) or die('Unable to select database: ' . mysql_error());
$submitted = false;
//Checking if values were passed
if (isset($_POST['area']) &&
isset($_POST['type']) &&
isset($_POST['price']) &&
isset($_POST['bedrooms']) &&
isset($_POST['fullbath']) &&
isset($_POST['halfbath']) &&
isset($_POST['sqft']))
//if passed, set variables accordingly
{
$area = get_post('area');
$type = get_post('type');
$price = get_post('price');
$bedrooms = get_post('bedrooms');
$fullbath = get_post('fullbath');
$halfbath = get_post('halfbath');
$sqft = get_post('sqft');
$submitted = true;
}
//optional field
if (isset($_POST['remarks']))
{
$remarks = get_post('remarks');
}
else
{$remarks = '';}
//form HTML
echo <<<_END
<form action="addform.php" method="post">
Area: <select name="area" size="1">
<option value="Hoboken">Hoboken</options>
<option value="Jersey City">Jersey City</options>
<option value="Weehawken">Weehawken</options>
</select><br />
Type: <select name="type" size="1">
<option value="rent">Rental</options>
<option value="sale">Sale</options>
<option value="commercial">Commercial</option>
</select><br />
Price: <input type="text" name="price" /><br />
Bedrooms: <input type="text" name="bedrooms" /><br />
Full Bathrooms: <input type="text" name="fullbath" /><br />
Half Bathrooms: <input type="text" name="halfbath" /><br />
Square Feet: <input type="text" name="sqft" /><br />
Remarks: <textarea name="remarks" wrap="soft" /><br />
<input type="submit" value="Add Listing" />
</form>
<br />
<br />
_END
//if data was provided, insert it into database and confirm
if ($submitted) {
$query = "INSET INTO bix (area, type, price, bedrooms, fullbath, halfbath, sqft, remarks) VALUES('$area', '$type', '$price', $bedrooms', '$fullbath', '$halfbath', '$sqft', '$remarks')";
if (mysql_query($query)){
echo "listing inserted.<br /></br />";
} else {
echo "insert fail: $query <br /><br />";
}
}
後にセミコロンが欠けている
INSERT
すると、あなたの代わりに$bedrooms'
の
'$bedrooms'
を望むならば、ちょうど私がdatabase--を閉じたことがないことに気づいたが、私はそれが解析エラーを引き起こしたとは思わない? – mavixあなたにはおそらくaがありません。 62. – ppp
mavix:1)これは解析エラーです。最初の解析、次に実行。 2)スクリプトが終了するとPHPは自動的に閉じます。 –