Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Can';在这个表单中找不到错误_Php_Html_Syntax - Fatal编程技术网

Php Can';在这个表单中找不到错误

Php Can';在这个表单中找不到错误,php,html,syntax,Php,Html,Syntax,这是基本的东西,但我不能让下面的表单可靠地处理。页面的名称是inplain.php。它偶尔起作用。该页面仅列出“平台”表中的所有值,并允许用户添加记录和刷新 <? session_start(); if (!isset($_SESSION['id_customer'])) { die ("Access Denied"); } include "../inc/db.php"; if (isset($_POST['submit'])) { $platform

这是基本的东西,但我不能让下面的表单可靠地处理。页面的名称是inplain.php。它偶尔起作用。该页面仅列出“平台”表中的所有值,并允许用户添加记录和刷新

<?
session_start();
   if (!isset($_SESSION['id_customer'])) { die ("Access Denied"); }
   include "../inc/db.php";


   if (isset($_POST['submit'])) {

     $platform = $_POST['platform'];

     $created = date("Y-m-d H:i:s");

     $query = "INSERT INTO Platform (id_platform, platform, date_created, date_modified) VALUES ('', $platform, '$created', '$created')";
     mysql_query($query);
     mysql_close();

     header("Location: inplain.php");
     }


      echo $passage;

?>




<table cellpadding="15">
        <tr>
            <td valign="top" width="50%">
            <?                   
            $sell_result = mysql_query("SELECT COUNT(id_platform) FROM Platform");
            $sell_count=mysql_fetch_array($sell_result);
            ?>
            The following <?=$sell_count['COUNT(id_platform)']?> categories exist in Platform. | <a href="inlist.php">Add Game...</a>
            <div style="height: 250px; overflow: auto;">
                <ul>
                <?
                    $result = mysql_query("
                                        SELECT * FROM Platform");
                    while($row = mysql_fetch_array($result)) {
                ?>
                    <li>

                                            <a href="inwant.php?addswaps=1&cat=Sell&col=sell&hid=<?=$row['id_platform']?>"><?=$row['id_platform']?></a> - <?=$row['platform']?>
                        <img src="../images/dot.png" width="1" height="20" border="0" /> 
                        <a href="inplain.php?remove=1&cat=Platform&col=platform&pid=<?=$row['id_platform']?>"><img src="../images/delete.jpg" width="15" height="15" border="0" alt="Delete" /></a>
                    </li>
                <? } ?>
                </ul>
            </div>
        </td>           
    </tr>   
<tr>
<td>
    <form name="inplain.php" method="post">
        Add a new platform: 
        <br />
            <input type="text" name="platform" size="30" /><BR>
            <input type="submit" id="submit" name="submit" value="Add" />

    </form>
</td>
</tr>
</table>

您应该输出mysql查询的结果,并使用mysql\u error函数确定查询中是否有时出现了故障。我注意到您没有在insert中对$platform变量加引号,因此这可能是一个问题

另外,请注意,脚本容易受到sql注入的攻击。在插入$platform字符串之前,需要使用mysql\u real\u escape\u字符串对其进行转义


最后,在提交逻辑中,在发出重定向回脚本的头之后,您应该放置一个die()命令,在浏览器重定向时停止脚本的任何进一步处理。不需要,但良好的做法。

您需要在写入
位置
标题后退出
。编写额外的输出可能会破坏重定向。

可能值得检查MySQL和PHP的错误日志


失败是否可能与调用脚本的位置有关,因为我注意到您的数据库详细信息位于包含相对路径中。如果此脚本也是“包含”的,而不是直接运行,则可能该相对路径并不总是正确的?

“它已损坏。请修复它。您不需要知道它是如何损坏的”。也许,如果您修复了SQL注入漏洞,它就不会像以前那样坏了。剩下的时间里,我拿出所有sql注入的东西来找出它为什么不能工作,Marc.
echo$passion将不会输出任何内容…谢谢,我感谢您的建议。我确实有强制的sql注入保护,我只是把它剥离到原始数据中,这样我就可以试着找出它不起作用的原因。
$password = mysql_real_escape_string($_POST['password']);

if ($_POST['Submit'] == 'Add' & $password == 'xyd')  {

$platform = mysql_real_escape_string($_POST['platform']);

$created = date("Y-m-d H:i:s");

$query = "INSERT INTO Platform (id_platform, platform, date_created, date_modified) VALUES ('', '$platform', '$created', '$created')";
mysql_query($query);
mysql_close();
  header("Location: inplain.php");
    die();
}