I am new to PHP, using DreamWeaver.
我是PHP新手,使用DreamWeaver。
However, I'm looking for someone to help me finish this.
但是,我正在找人帮我完成这个。
I have 3 tables in MYSQL that are
我在MYSQL中有3个表
Championships
- idChampionships,
- Name
- Details
Users
- idUsers
- UserName
- Password
participants
- idparticipants
- idChampionships
- FirstName
- LastName
- DateOfBirth
- NationalRanking
- Photo
- PhoneNumber
- EmailAddress
- IdUsers
What i'm trying to do is taking 2 existed ID's in Championships, Users
and insert them to the participants table on submitting the form to identify which championship he's participating in and who is that user. to avoid duplications.
我想要做的是在锦标赛中使用2个已存在的ID,用户并将其插入参与者表格,提交表格以确定他参加的冠军以及该用户是谁。避免重复。
It appears i have a parsing error that i cannot figure it out, which is indicated in the last line.
看来我有一个解析错误,我无法弄明白,这在最后一行中指出。
Please help!
Here is the code
这是代码
<?php require_once('Connections/ACBSEntrySystem.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO participants (idparticipants, idChampionships, FirstName, LastName, DateOfBirth, NationalRanking, Photo, PhoneNumber, EmailAddress, IdUsers) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['idparticipants'], "int"),
GetSQLValueString($_POST['idChampionships'], "int"),
GetSQLValueString($_POST['FirstName'], "text"),
GetSQLValueString($_POST['LastName'], "text"),
GetSQLValueString($_POST['DateOfBirth'], "date"),
GetSQLValueString($_POST['NationalRanking'], "int"),
GetSQLValueString($_POST['Photo'], "text"),
GetSQLValueString($_POST['PhoneNumber'], "double"),
GetSQLValueString($_POST['EmailAddress'], "text"),
GetSQLValueString($_POST['idUsers'], "int"));
mysql_select_db($database_ACBSEntrySystem, $ACBSEntrySystem);
$Result1 = mysql_query($insertSQL, $ACBSEntrySystem) or die(mysql_error());
}
mysql_select_db($database_ACBSEntrySystem, $ACBSEntrySystem);
$query_AvailableChampionships = "SELECT idChampionships, Name FROM Championships ORDER BY Name ASC";
$AvailableChampionships = mysql_query($query_AvailableChampionships, $ACBSEntrySystem) or die(mysql_error());
$row_AvailableChampionships = mysql_fetch_assoc($AvailableChampionships);
$totalRows_AvailableChampionships = mysql_num_rows($AvailableChampionships);
mysql_select_db($database_ACBSEntrySystem, $ACBSEntrySystem);
$query_ActiveUser = "SELECT idUsers FROM Users";
$ActiveUser = mysql_query($query_ActiveUser, $ACBSEntrySystem) or die(mysql_error());
$row_ActiveUser = mysql_fetch_assoc($ActiveUser);
$totalRows_ActiveUser = mysql_num_rows($ActiveUser);
mysql_select_db($database_ACBSEntrySystem, $ACBSEntrySystem);
$query_InsertingARecord = "SELECT * FROM participants";
$InsertingARecord = mysql_query($query_InsertingARecord, $ACBSEntrySystem) or die(mysql_error());
$row_InsertingARecord = mysql_fetch_assoc($InsertingARecord);
$totalRows_InsertingARecord = mysql_num_rows($InsertingARecord);
?>
The form starts from here, in the body of the HTML
表单从这里开始,在HTML的正文中
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">IdChampionships:</td>
<td><select name="idChampionships">
<?php
do {
?>
<option value="<?php echo $row_AvailableChampionships['idChampionships']?>" ><?php echo $row_AvailableChampionships['Name']?></option>
<?php
} while ($row_AvailableChampionships = mysql_fetch_assoc($AvailableChampionships));
?>
</select></td>
<tr>
<tr valign="baseline">
<td nowrap align="right">FirstName:</td>
<td><input type="text" name="FirstName" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">LastName:</td>
<td><input type="text" name="LastName" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">DateOfBirth:</td>
<td><input type="text" name="DateOfBirth" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">NationalRanking:</td>
<td><input type="text" name="NationalRanking" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Photo:</td>
<td><input type="text" name="Photo" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">PhoneNumber:</td>
<td><input type="text" name="PhoneNumber" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">EmailAddress:</td>
<td><input type="text" name="EmailAddress" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
A loop for the Users starts here to echo the idUser
用户的循环从此处开始回显idUser
<input type="hidden" name="idparticipants" value="">
<input type="hidden" name="IdUsers" value="<?php do {echo $row_ActiveUser['idUsers'];while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));?>">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</div>
</div>
</div>
</section>
<!--==============================footer================================-->
<?php include("../include/footer.php");?>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($AvailableChampionships);
mysql_free_result($ActiveUser);
mysql_free_result($InsertingARecord);
?>
There error am getting is
我得到的错误是
Parse error: syntax error, unexpected $end in /Applications/XAMPP/xamppfiles/htdocs/entryform.php on line 191
解析错误:语法错误,第191行/Applications/XAMPP/xamppfiles/htdocs/entryform.php中的意外$ end
1 个解决方案
#1
0
Your do-while loop is missing a closing curly brace.
你的do-while循环缺少一个结束大括号。
`value="<?php do {echo $row_ActiveUser['idUsers'];while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));?>">`
should be
value="<?php
do {
echo $row_ActiveUser['idUsers'];
} while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));
?>">
#1
0
Your do-while loop is missing a closing curly brace.
你的do-while循环缺少一个结束大括号。
`value="<?php do {echo $row_ActiveUser['idUsers'];while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));?>">`
should be
value="<?php
do {
echo $row_ActiveUser['idUsers'];
} while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));
?>">