PHP无缘无故地显示代码

时间:2013-12-03 11:40:10

标签: php html apache echo

我有一个PHP文件函数,在代码中的某一点它开始将所有内容回显到屏幕上,但代码仍然有用。

最初我认为回声没有正确关闭,但似乎是,即使我注释掉回声,它仍会将其打印到屏幕上。

下面是代码开始显示的代码示例。

   $conn = mysql_connect('localhost', 'root', '');         //Details to connect to the specific database and table, password is left blank
    mysql_select_db('amazondb', $conn);                     //mysql command to pick the specific database and runs the connection 
            //Clear data from Table
    mysql_query ("TRUNCATE TABLE imported_orders2");         //Runs mysql query to delete all data in the specified table
        //Informs User
    //echo "<br>Uploaded File: <br>";  //Tells the user the name of the file they have uploaded
    //echo "<br>Uploaded File: " . $_FILES["file"]["name"] . "<br>";  //Tells the user the name of the file they have uploaded

        //Move uploaded file
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);       //When the file is first uploaded it is saved in a temporary location and only exists while the php is running, this moves the file to a specific folder permanently
        //Delete first Line

Here是指向我突出显示的内容的屏幕截图的链接,其中所有内容都显得格格不入。

2 个答案:

答案 0 :(得分:0)

检查您的PHP文件是否具有正确的PHP Open标记和Close标记。

如果是,请检查您的PHP.INI文件是否短开标签,如果是关闭更改您的PHP开放标记或更改您的PHP.INI文件短开标签是开。

答案 1 :(得分:0)

我认为你在代码中使用$_FILES["File"]["Name"]之前关闭了php标记。

您可以尝试替换

$_FILES["File"]["Name"]

通过

<?php echo $_FILES["File"]["Name"]; ?>

它会显示文件名。