0

我是 PHP 新手,使用 DreamWeaver。

不过,我正在找人帮我完成这件事。

我在 MYSQL 中有 3 个表

锦标赛

  • idChampionships ,
  • 姓名
  • 细节

用户

  • idUsers
  • 用户名
  • 密码

参与者

  • id参与者
  • idChampionships
  • 出生日期
  • 全国排名
  • 照片
  • 电话号码
  • 电子邮件地址
  • 用户名

我正在尝试做的是Championships, Users在提交表单时将 2 个现有 ID 插入到参与者表中,以确定他正在参加的锦标赛以及该用户是谁。以避免重复。

看来我有一个我无法弄清楚的解析错误,这在最后一行中指出。

请帮忙!

这是代码

<?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);
?>

表单从这里开始,在 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">&nbsp;</td>
                  <td><input type="submit" value="Insert record"></td>
                </tr>
              </table>
              

用户的循环从这里开始以回显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>&nbsp;</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);
    ?>

我得到的错误是

解析错误:语法错误,第 191 行 /Applications/XAMPP/xamppfiles/htdocs/entryform.php 中的意外 $end

4

1 回答 1

0

您的 do-while 循环缺少右花括号。

`value="<?php do {echo $row_ActiveUser['idUsers'];while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));?>">`

应该

value="<?php
do {
    echo $row_ActiveUser['idUsers'];
} while ($row_ActiveUser = mysql_fetch_assoc($ActiveUser));
?>">
于 2013-06-30T05:28:33.987 回答