批准和拒绝MySQL和PHP不工作 这是不推荐使用的MySQL。 是的,我知道我应该皈依。 请列出有用的意见。如果您想尝试将其更改为mysqli,请继续:P

批准和拒绝MySQL和PHP不工作 这是不推荐使用的MySQL。 是的,我知道我应该皈依。 请列出有用的意见。如果您想尝试将其更改为mysqli,请继续:P,php,mysql,Php,Mysql,出于某种原因,当我试图批准或拒绝提交时,它不会。示例:用户提交的广告。批准|拒绝您单击批准按钮或拒绝按钮,它会将您带回员工面板,提交内容仍然存在,并且仍然在提交的数据库中,而不是在ads数据库中。我经营一个目录广告网站 <?php $Page_Name = "Pending Submissions"; include("/home/idirecto/public_html/includes/global.php"); ?> <!doctype html> <ht

出于某种原因,当我试图批准或拒绝提交时,它不会。示例:用户提交的广告。批准|拒绝您单击批准按钮或拒绝按钮,它会将您带回员工面板,提交内容仍然存在,并且仍然在提交的数据库中,而不是在ads数据库中。我经营一个目录广告网站

<?php 
$Page_Name = "Pending Submissions";
include("/home/idirecto/public_html/includes/global.php"); 
?>
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8"/>
<title><?=SiteName;?> - Staff Panel - <?=PageName;?></title>

<link rel="stylesheet" href="css/layout.css" type="text/css" media="screen" />
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" />
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<?php 
include("./includes/javascript.php"); 
?>
</head>


<body>
<?php
if($logged_in && preg_match("/group(1)([^\d]|$)/", $user_info['group'])) {  
include("./includes/header.php"); 
include("./includes/sidebar.php"); 
?>

<section id="main" class="column">

<?php
$connection = mysql_connect($DBhost, $DBuser, $DBpass) or     die(mysql_error()); 
        mysql_select_db($DBname, $connection) or die(mysql_error());  
        $id = $_POST['id'];
        $image = htmlentities($_POST['image']);
        $url = htmlentities($_POST['url']);
        $title = htmlentities($_POST['title']);
        $desc = htmlentities($_POST['desc']);
        $category = htmlentities($_POST['category']);
        $user = htmlentities($_POST['user']);
        $approve = isset($_POST['approve']);
        $deny = isset($_POST['deny']);
        $send_submit = isset($_POST['edit_submit']);
        $EmailFroms = "From: iDirectory <submit@idirectoryads.com>";
        $EmailTo = Trim(stripslashes($_POST['email'])); 
        $Subject = "iDirectory Submission";
        $validationOK=true;
        if (Trim($EmailTo)=="") $validationOK=false;

        if($deny){
            if (!$validationOK) {
                echo "<h4 class=\"alert_error\">An error occurred: The email address could not be validated.</h4>";
                include("./includes/submission_pending.php");
            } else {
                $Body = "Thank you for submitting your website to iDirectory. \n \n The site : $_POST[title] ($_POST[url]) \n has been denied submission. \n \n The reason your submission was denied could be that \n it contained content that does not pass our TOU. For more \n information please visit out support forum. \n http://www.support.idirectoryads.com \n \n Regards, \n iDirectory Staff \n --------------------------------------------------------- \n You received this as a result of submitting, a website \n into our database. We will not reveal or share your personal \n information without your permission.";
                $success = mail($EmailTo, $Subject, $Body, $EmailFroms);
                $rt1 = mysql_query("DELETE FROM submit WHERE id= '".$id."'");
                if ($success && $rt1){
                    echo "<h4 class=\"alert_success\">The submission has been denied.</h4>";
                    include("./includes/submission_pending.php");
                } else {
                    echo "<h4 class=\"alert_error\">An error occurred: The submission could not be denied.</h4>";
                       include("./includes/submission_pending.php");
                }
            }
        } else if($approve && $_POST['status'] == 'Edited'){ 
            if (!$validationOK) {
                echo "<h4 class=\"alert_error\">An error occurred: The email address could not be validated.</h4>";
                include("./includes/submission_pending.php");
            } else {
                $Body = "Thank you for submitting your website to iDirectory. \n \n Your requested updates to the site : $_POST[title] ($_POST[url]) \n has been approved. \n \n We thank you for your service. If you have any comments \n or questions feel free to visit our support forum. \n http://www.support.idirectoryads.com \n \n Regards, \n
                iDirectory Staff \n --------------------------------------------------------- \n You received this as a result of updating information you \n have submitting into our database. We will not reveal \n or share your personal information without your permission.";
                $success = mail($EmailTo, $Subject, $Body,   $EmailFroms);
                $update_submission = mysql_query("UPDATE ads SET  title='".$title."', image='".$image."', url='".$url."', `desc`='".$desc."',  category='".$category."' WHERE id='".$id."'") or die(mysql_error());
                $rt1 = mysql_query("INSERT INTO ads WHERE id=  '".$id."'");
                if($success && $update_submission && $rt1)
                {
                    echo "<h4 class=\"alert_success\">The submission has been approved.</h4>";
                    include("./includes/submission_pending.php");
                } else {
                    echo "<h4 class=\"alert_error\">An error occurred: The submission couldn't be approved.</h4>";
                    include("./includes/submission_pending.php");
                }
            }
        } else if($approve && $_POST['status'] == 'New'){ 
            if (!$validationOK) {
                echo "<h4 class=\"alert_error\">An error occurred:  The email address could not be validated.</h4>";
                include("./includes/submission_pending.php");
            } else {
                $Body = "Thank you for submitting your website to  iDirectory. \n \n The site : $_POST[title] ($_POST[url]) \n has been approved. \n \n We thank you for your service. If you have any comments \n or questions feel free to visit our  support forum. \n http://www.support.idirectoryads.com \n \n Regards, \n
                iDirectory Staff \n --------------------------------------------------------- \n You received this as a result of submitting, a website \n into our database. We will not reveal or share your personal \n information without your permission.";
                $success = mail($EmailTo, $Subject, $Body,  $EmailFroms);
                $insert_submission = mysql_query("INSERT INTO ads  (title, image, url, `desc`, category, user) VALUES ('".$title."', '".$image."', '".$url."', '".$desc."', '".$category."', '".$user."')");
                $rt1 = mysql_query("DELETE FROM submit WHERE id = '".$id."'");
                if ($success && $insert_submission && $rt1){
                    echo "<h4 class=\"alert_success\">The submission has been approved.</h4>";
                    include("./includes/submission_pending.php");
                } else {
                    echo "<h4 class=\"alert_error\">An error occurred: The submission couldn't be approved.</h4>";
                    include("./includes/submission_pending.php");
                }   
            }               
        } else {
            include("./includes/submission_pending.php");
        }
    echo "</section>"; 
    mysql_close($connection);
} else {
    include("./includes/login.php"); 
}
?>
</body>
</html>
标题需要与远程托管论坛的API保持一致

问题:如果这已经更新到MySQLi,那么我在每个页面中的其余代码是否都必须更新

我已经做了好几个小时了,查看文档,修改代码,但我还是得到了一个空白页,或者做了上面代码所做的事情

如果你需要更多的编码,让我知道

谢谢。

htmlspecialchars甚至还没有接近。更新您的所有页面不是一个坏主意,因为如果您忘记正确地逃避问题,mysql_查询将是一个坏消息。好消息是,您可以一次清理一个文件,只要您有一个新的数据库框架可以使用

您可能要做的是选择一些更现代的东西,比如PDO,并逐步删除旧的mysql_查询代码。只要每个页面都有自己的连接,就像这里一样,你就没事了

接下来,您将需要适当的连接池,以避免在每次页面加载时产生巨大的连接损失。这是一件大事

当您检修应用程序时,可以使用git grep mysql_query之类的工具来衡量您还需要做多少工作


如果您没有版本控制系统或测试服务器,那么在开始大修应用程序之前,您需要先进行设置。改变这类东西并不总是像我们希望的那么容易,因此能够恢复错误并测试应用程序是至关重要的。像这样的工具可以非常容易地获得与您的生产环境非常接近的运行时。

问题:如果已将其更新到MySQLi,是否需要更新每个页面中的其余代码?-简短回答:否/长回答:只要不更改任何列等或任何包含的DB连接文件,你应该没事的。您似乎拥有的包含文件不应在其他文件中使用,因为它们存在持有不同API的风险;我认为您需要确认您认为调用此函数的表单正在传递的参数确实正在传递。放上大量的回音语句,看看你提出了什么要求,或者只是打印帖子;在文件的begining中放入print\u r$\u POST,在提交Deny按钮后,复制它输出的内容并粘贴到您的POST中;这句话是无效的,也没有意义。这能解释为什么你被派到了错误的地方吗?@RiggsFolly你是对的,尽管使用不同的方法=>和上面的一些例子是有可能的-只是做得稍有不同而已。@Darkmage如果你要进行一次非常认真的大修,你必须消化并写出其中的一部分,您可能希望迁移到,以便为新应用程序提供更多的结构并使其更易于维护。框架提供了很多支持,随着数据库接口的变化,框架将几乎毫不费力地推动您前进。通过将代码插入文件来编写PHP不是一个可伸缩的解决方案,正如您所看到的,它很难升级。我查看了该网站,谢谢!我去看看能用什么。