dsqbkh3630
dsqbkh3630
2013-03-27 14:29
浏览 125
已采纳

解析错误:语法错误,第83行的C:\ xampp \ htdocs \ eg \ submit.php中的文件意外结束[关闭]

<html>
<body>

<?php include("header.php"); ?>
   <?php include("menu.php"); ?>
   <?php
$host = 'localhost';
$user = 'root';
$password = '';

$database = 'egov';

$conn = mysql_connect($host,$user,$password) or die('Server Information is not Correct');
mysql_select_db($database,$conn) or die('Database Information is not correct');


$sql = "CREATE TABLE IF NOT EXISTS  'upload'(file_id INT(11) NOT NULL,fName VARCHAR(255) NOT NULL,lName VARCHAR(255) NOT NULL,Mo INT(11) NOT NULL,dese VARCHAR(255) NOT NULL,Email VARCHAR(255) NOT NULL,file_name VARCHAR(255) NOT NULL,PRIMARY KEY(file_id))ENGINE = MYISAM";


if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}


$da = date("dmy");
echo $da;



$fname = $_REQUEST['lastname'];
$lname = $_REQUEST['firstname'];
$pno = $_REQUEST['mbo'];
$email = $_REQUEST['email'];
$query = $_REQUEST['description'];




$sql = "INSERT INTO upload (
                    fName,
                    lName,
                    Mo,
                    dese,
                    Email                   
                )
                VALUES (
                    '$fname',
                    '$lname',
                    '$pno',
                    '$email',
                    '$query ',
                    'file_name',
                    NOW()
                )";





include'index.php';


?>
<?php include("copyrights.php"); ?> 

            </div>
    </div>
</body>
</html>

please some one help me am getting an parse error while inserting data into mysql database through my script

ive also changed its code like to:

?>

still not working... its showing the same error as unexpected ending and thanks in advance ........

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongluan2612
    dongluan2612 2013-03-27 14:35
    已采纳

    Ending the if (isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) as @MarkoD pointed out will resolve the unexpected end of file:

    <?php
    include("header.php");
    ?>
       <?php
    include("menu.php");
    ?>
       <?php
    $host     = 'localhost';
    $user     = 'root';
    $password = '';
    
    $database = 'egov';
    
    $conn = mysql_connect($host, $user, $password) or die('Server Information is not Correct');
    mysql_select_db($database, $conn) or die('Database Information is not correct');
    
    
    $sql = "CREATE TABLE IF NOT EXISTS  'upload'(file_id INT(11) NOT NULL,fName VARCHAR(255) NOT NULL,lName VARCHAR(255) NOT NULL,Mo INT(11) NOT NULL,dese VARCHAR(255) NOT NULL,Email VARCHAR(255) NOT NULL,file_name VARCHAR(255) NOT NULL,PRIMARY KEY(file_id))ENGINE = MYISAM";
    
    
    if (isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) {
        $fileName = $_FILES['userfile']['name'];
        $tmpName  = $_FILES['userfile']['tmp_name'];
        $fileSize = $_FILES['userfile']['size'];
        $fileType = $_FILES['userfile']['type'];
    
        $fp      = fopen($tmpName, 'r');
        $content = fread($fp, filesize($tmpName));
        $content = addslashes($content);
        fclose($fp);
    
        if (!get_magic_quotes_gpc()) {
            $fileName = addslashes($fileName);
        }
    
    
        $da = date("dmy");
        echo $da;
    
    
    
        $fname = $_REQUEST['lastname'];
        $lname = $_REQUEST['firstname'];
        $pno   = $_REQUEST['mbo'];
        $email = $_REQUEST['email'];
        $query = $_REQUEST['description'];
    
    
    
    
        $sql = "INSERT INTO upload (
                        fName,
                        lName,
                        Mo,
                        dese,
                        Email                   
                    )
                    VALUES (
                        '$fname',
                        '$lname',
                        '$pno',
                        '$email',
                        '$query ',
                        'file_name',
                        NOW()
                    )";
    
    
    }
    
    
    include 'index.php';
    
    
    ?>
    <?php
    include("copyrights.php");
    ?> 
    
    点赞 评论

相关推荐