将另一个表的数据插入一个表中

时间:2016-10-22 08:27:18

标签: php mysql

此查询应该将成员表行复制到membersd表中,然后从成员表中删除该行。当然,还有更多内容,但INSERT查询是不起作用的。这是第一个查询的正确语法吗?我只是一个初学者,但看起来它缺少一些简单的东西。

<?php
    require 'class.phpmailer.php';
    if(isset($_POST['submit']))
    {
        $mail = new PHPMailer;
        $mail->isSMTP();
        $mail->Host = 'webmail.example.com';
        $mail->Port = 587;
        $mail->SMTPSecure = 'tls';
        $mail->SMTPAuth = true;
        $mail->Username = 'digital';
        $mail->Password = '*******';
        $mail->setFrom('digital@example.com', 'example');
        $mail->addReplyTo('sales@example.com', 'example');
        $mail->addAddress('sales@example.com', 'example');
        $name_field = $_POST['name'];
        $mobile_field = $_POST['mobile'];
        $project_field = $_POST['project'];
        $utm_source_field = $_POST['USOURCE'];
        $utm_medium_field = $_POST['UMEDIUM'];
        $utm_campaign_field = $_POST['UCAMPAIGN'];

        $mail->Subject = "Website Inquiry - $project_field";
        $mail->msgHTML($body);

        if (!$mail->send()) {
            $error = "Mailer Error: " . $mail->ErrorInfo;
            ?>
            <script>alert('<?php echo $error ?>');</script><?php
        } 
        else {
            echo '';
            header("Location: thankyou.html");
        }
    }
?>

1 个答案:

答案 0 :(得分:0)

也许你错过了mysql查询的第二个参数,它是连接对象$ con或者什么

  

mysql_query($ sql,$ con);

你可能已经像这样定义了

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'rootpassword';
$con    = mysql_connect($dbhost, $dbuser, $dbpass);