Тема: PHP код для небольшой админки. Ошибка.
Вот есть такой код, написанный по аналогии с кодом из учебника:
-----------------------------------------------------
Тут много кода, не касающегося проблемы.
------------------------------------------------------
...
...
...
function edit_record()
{
global $default_dbname, $user_tablename;
$PHP_SELF = $_SERVER['PHP_SELF'];
$userid = $_GET["userid"];
$Section = $_GET["Section"];
$Docname = $_GET["Docname"];
$Surname = $_GET["Surname"];
$Name = $_GET["Name"];
$Patronymic = $_GET["Patronymic"];
$Email = $_GET["Email"];
$Telephone = $_GET["Telephone"];
$Sex = $_GET["Sex"];
$Date = $_GET["Date"];
$Country = $_GET["Country"];
$Region = $_GET["Region"];
$City = $_GET["City"];
$School = $_GET["School"];
$Address = $_GET["Address"];
if(empty($userid)){
$userid = $_GET['new_userid'];
}
$link_id = db_connect($default_dbname);
if(!$link_id){
error_message(sql_error());
}
$field_str = ";
if($userid != $new_userid) $field_str = " userid = '$newuserid', ";
$field_str .= " Surname = '$Surname', ";
$field_str .= " Name = '$Name', ";
$field_str .= " Patronymic = '$Patronymic', ";
$field_str .= " Email = '$Email'";
$field_str .= " Telephone = '$Telephone'";
$field_str .= " Sex = '$Sex'";
$field_str .= " Date = '$Date'";
$field_str .= " Country = '$Country'";
$field_str .= " Region = '$Region'";
$field_str .= " City = '$City'";
$field_str .= " School = '$School'";
$field_str .= " Address = '$Address'";
$query = "UPDATE IGNORE $user_tablename SET $field_str WHERE userid = '$userid'";
$result = mysql_query($query);
if(!$result){
error_message(sql_error());
}
$num_rows = mysql_affected_rows($link_id);
if(!$num_rows){
error_message("Ни одна запись не изменена!");
}
function view_record() {
global $default_dbname, $user_tablename, $access_log_tablename;
global $position_array; $userid = $_GET['userid'];
$PHP_SELF = $_SERVER['PHP_SELF'];
if(empty($userid)){
error_message('Введите идентификатор пользователя!');
}
$link_id = db_connect($default_dbname);
if(!$link_id){
error_message(sql_error());
}
$query = "SELECT usernumber, userid, username, userposition, useremail,
userprofile FROM $user_tablename WHERE userid = '$userid'";
$result = mysql_query($query);
if(!$result){
error_message(sql_error());
}
$query_data = mysql_fetch_array($result);
$userid = $query_data["userid"];
$Section = $query_data["Section"];
$Docname = $query_data["Docname"];
$Surname = $query_data["Surname"];
$Name = $query_data["Name"];
$Patronymic = $query_data["Patronymic"];
$Email = $query_data["Email"];
$Telephone = $query_data["Telephone"];
$Sex = $query_data["Sex"];
$Date = $query_data["Date"];
$Country = $query_data["Country"];
$Region = $query_data["Region"];
$City = $query_data["City"];
$School = $query_data["School"];
$Address = $query_data["Address"];
html_header();
echo "<center><H3>
Запись для пользователя №
</h3></center>";
?>
<form method="get" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="action" value="edit_record">
<input type="hidden" name="userid" value="<? echo $userid ?>">
<div align="center"><center>
<table border="1" width="90%" cellpadding="2">
<tr>
<th width="30%" nowrap>Идентификатор</th>
<td width="70%">
<input type="text" name="new_userid"
value="<?php echo $userid ?>"
size="8" maxlength="8"></td>
</tr>
<tr>
<th width="30%" nowrap>Секция</th>
<th width="70%"><input type="text" name="Section"
value="<?php echo $Section ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Название доклада</th>
<th width="70%"><input type="text" name="Docname"
value="<?php echo $Docname ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Фамилия</th>
<th width="70%"><input type="text" name="Surname"
value="<?php echo $Surname ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Имя</th>
<th width="70%"><input type="text" name="Name"
value="<?php echo $Name ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Отчество</th>
<th width="70%"><input type="text" name="Patronymic "
value="<?php echo $Patronymic ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Email</th>
<th width="70%"><input type="text" name="Email"
value="<?php echo $Email ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Telephone</th>
<th width="70%"><input type="text" name="Telephone"
value="<?php echo $Telephone ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Sex</th>
<th width="70%"><input type="text" name="Sex"
value="<?php echo $Sex ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Date</th>
<th width="70%"><input type="text" name="Date"
value="<?php echo $Date ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Country</th>
<th width="70%"><input type="text" name="Country"
value="<?php echo $Country ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Region</th>
<th width="70%"><input type="text" name="Region"
value="<?php echo $Region ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>City</th>
<th width="70%"><input type="text" name="City"
value="<?php echo $City ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>School</th>
<th width="70%"><input type="text" name="School"
value="<?php echo $School ?>" SIZE="20"></td>
</tr>
<tr>
<th width="30%" nowrap>Address</th>
<th width="70%"><input type="text" name="Address"
value="<?php echo $Address ?>" SIZE="20"></td>
</tr>
<tr>
<th width="100%" colspan="2" nowrap>
<input type="submit" value="Записать">
<input type="reset" value="Очистить">
</th>
</tr>
</table>
</center></div>
</form>
<?php
echo "<HR SIZE=\"2\" WIDTH=\"90%\">\n";
?>
</TR>
</TABLE>
</DIV>
<?php
}
html_footer();
}
if (empty($_GET['action'])){
$_GET['action'] = "";
}
switch($_GET['action']) {
case "edit_record":
edit_record();
break;
case "delete_record":
delete_record();
break;
case "view_record":
view_record();
break;
default:
list_records();
break;
}
?>
Но при запуске появляется ошибка Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\admin1\userviewer.php on line 265
Строка 265 вот эта:
if($userid != $new_userid) $field_str = " userid = '$newuserid', ";