-4

私は初心者です

以下は私のHTML PHPフォームです

<div id="user">
<form name="booksInput" action="theGamer.php" method="post">
<p>This Section is to add new USer Record in DB</p>
User F Name: <input type="text" name="Fuser">
User L Name: <input type="text" name="Luser">
<?php
$con=mysql_connect("localhost","root","","library");
mysql_select_db("library",$con);
$sqlb = "SELECT * FROM books";
$queryb = mysql_query($sqlb);
while ($resultsb[] = mysql_fetch_object ( $queryb ));
?>
Book Name:<select name="bID">
<?php foreach ( $resultsb as $optionb ) { ?>
<option value="<?php echo $optionb->bID; ?>"><?php echo $optionb->book;?></option>
<?php } ?>
</select><br>
<?php               
$con=mysql_connect("localhost","root","","library");
mysql_select_db("library",$con);
$sqlc = "SELECT * FROM country";
$queryc = mysql_query($sqlc);
while ( $resultsc[] = mysql_fetch_object ( $queryc ) );
array_pop($resultsc);
?>
Country Name:<select name="cID">
<?php foreach ( $resultsc as $optionc ) : ?>
<option value="<?php echo $optionc->cID; ?>"><?php echo $optionc->country;?>/option

    <?php endforeach; ?>
</select>
<input type="submit" value="Submit" name="subUser">
</form> 
    </div>

送信ボタンの名前付けsunUserが押されたときにtheGamer.php指示され、コードtheGamer.phpは以下のとおりです

<?php
$con=mysql_connect("localhost","root","","library");
function insertBook()
{
global $con;
mysql_select_db("library",$con);
$book=mysql_real_escape_string($_POST['books']);
$sql="INSERT INTO books (bID, book) VALUES ('','$book')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error($con));
}`
echo "1 record added";
}

function insertCountry()
{
global $con;
mysql_select_db("library",$con);
$country=mysql_real_escape_string($_POST['country']);
$sql="INSERT into country (cID, country) VALUES ('','$country')";

if (mysql_query($sql,$con))
{
echo "1 record added";
}
else{die('Error: ' . mysql_error($con));}

}

function insertUser()
{
$con=mysql_connect("localhost","root","","library");
mysql_select_db("library",$con);
$Fuser=mysql_real_escape_string($_POST['Fuser']);
$Luser=mysql_real_escape_string($_POST['Luser']);
$bID=mysql_real_escape_string($_POST['bID']);
$cID=mysql_real_escape_string($_POST['cID']);
$sql="INSERT INTO user (userid, uFname,uLname, bID, CID ) VALUES  
    ('','$Fuser','$Luser','bID','cID')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error($con));
}
echo "1 record added";
    }

   //Code for Knowing which button is pressed
  if(isset($_POST['subBooks']))
  {
  insertBook();
  } 
 if(isset($_POST['subCountry']))
 {
 insertCountry();
 }
if(isset($_POST['subUser']))
 {
 insertUser();
 } 
?> 

それはこのエラーを与えます 解析エラー: 20行目でT_STRINGor T_VARIABLEorT_NUM_STRINGを期待して解析エラーが発生しますが、ボタンが押され、ifステートメントが機能する必要があるC:\wamp\www\library\theGamer.phpため、行番号20にはnpの懸念があります なぜ20行目でエラーが発生するのですかsubUseru=insertuser

よろしくAp

4

1 に答える 1