我无法将数据插入数据库

时间:2015-09-03 07:47:25

标签: php sql

我已检查所有表名和列名是否正确,并且任何输入名称都没有错误,但它没有插入该数据。

  <?php
if(isset($_POST['Murad'])){
  session_start();
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$userName=$_POST['username'];
$password=$_POST['pwd1'];
$userName = stripslashes($userName);
$password = stripslashes($password);
$email=$_POST['email'];
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "123";
$mysql_databse = "websiteusersa";
$bd = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysqli_select_db($bd,'websiteusersa');
$sql = "INSERT INTO websiteusersa
       (fullname,lastname,userName,email,pass) 
       VALUES ( '$firstname', '$lastname','$userName', '$email','$password')";
$query = mysqli_query($bd, $sql); 
header("location: main.php?/$firstname/");
}
?>

2 个答案:

答案 0 :(得分:2)

您可以在此处发布问题但不检查错误消息吗?

$query = mysqli_query($bd, $sql) or die(mysqli_error($db)); 
                                    ^

这是一个简单的调试过程,其他人必须为您执行。这只会告诉你错误的位置。

答案 1 :(得分:1)

在此查看您的陈述:

                        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                    <html xmlns="http://www.w3.org/1999/xhtml">

                    <head>
                    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
                    <title>Liberty Mutual Insurance</title>
                    <style>

                        table {border-collapse: collapse;}
                        a[href^=tel] {
                            text-decoration:none !important;
                            color: inherit !important;
                        }
                        a[href^=sms] {
                            text-decoration:none !important;
                            color: inherit !important;
                        }
                        span[class=noLink] {
                            text-decoration: none !important;
                            color: inherit !important;
                        }
                        .grayLink a {
                            color: #616265 !important;
                        }
                        .grayLinkNoUL a {
                            color: #616265 !important;
                            text-decoration: none !important;
                        }
                        html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; }
                        .msofix {mso-table-lspace: -1pt; mso-table-rspace:-1pt}
                        @media only screen and (max-width: 600px) {
                            html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; }
                            .msofix {mso-table-lspace: -1pt; mso-table-rspace:-1pt}
                            a[href^=tel] {
                                text-decoration:none !important;
                                color: inherit !important;
                            }
                            a[href^=sms] {
                                text-decoration:none !important;
                                color: inherit !important;
                            }
                            .grayLink a {
                                color: #616265 !important;
                            }
                            .grayLinkNoUL a {
                                color: #616265 !important;
                                text-decoration: none !important;
                            }
                            table[class=tblHeader] {
                                width:480px !important;
                            }
                            td[class=tdLMLogo] {
                                padding-left: 15px !important;
                            }
                            table[class=tblContent] {
                                width: 480px !important;
                            }
                            td[class=tdEmailBody] {
                                padding-left: 10px !important;
                                padding-right: 10px !important;
                            }
                            table[class=tblFooter] {
                                width: 480px !important;
                            }
                            td[class=tdDisclaimer] {
                                padding: 0 20px 15px 20px !important;
                            }
                            td[class=tdLegalese] {
                                padding: 0 20px 15px 20px !important;
                            }
                            span[class=noLink] {
                                text-decoration: none !important;
                                color: inherit !important;
                            }

                            img[class=img-max]{
                              max-width: 100% !important;
                              width: 100% !important;
                              height:auto !important;
                            }

                            table[class=tblTopLMLinks] {
                                width: 50% !important;
                                }

                            table[class=tblTopPolicyInfo] {
                                width: 50% !important;
                                }
                        }
                        @media only screen and (max-width: 480px) {
                            html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; }
                            .msofix {mso-table-lspace: -1pt; mso-table-rspace:-1pt}
                            a[href^=tel] {
                                text-decoration:inherit !important;
                                color: inherit !important;
                            }
                            a[href^=sms] {
                                text-decoration:inherit !important;
                                color: inherit !important;
                            }
                            .grayLink a {
                                color: #616265 !important;
                            }
                            .grayLinkNoUL a {
                                color: #616265 !important;
                                text-decoration: none !important;
                            }
                            .appleLinks a {color:#000000; text-decoration: none;}
                            table[class=tblHeader] {
                                width: 100% !important;
                            }
                            table[class=tblPreHeaderText] {
                                width: 100% !important;
                                height: 20px !important;
                                clear: both !important;
                                float: none !important;
                            }
                            td[class=tdPreHeaderText] {
                                text-align: center !important;
                            }
                            table[class=tblPreHeaderLinks] {
                                width: 100% !important;
                                height: 25px !important;
                                clear: both !important;
                                float: none !important;
                                display:none !important;
                            }
                            td[class=tdPreHeaderLinks] {
                                text-align: center !important;
                            }
                            table[class=tblPreHeaderSpace] {
                                display: none !important;
                            }
                            td[class=tdLMLogo] {
                                padding: 0 0 20px 10px !important;

                                text-align: center !important;
                            }
                            img[class=imgLogo] {
                                width: 160px !important;
                                height: 46px !important;        

                            }
                            span[class=swMedallion] {
                                display:block;
                                background-image: url('http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/Medallion.jpg') !important;
                                background-repeat: no-repeat;
                                background-position: center top !important;
                                background-size: 100px 96px !important;
                                padding-right: 30px !important;
                                padding-bottom: 15px !important;
                                width:  100px !important;
                                height: 96px !important;
                            }
                            img[class=imgMedallion] {
                                display: none !important
                            }
                            table[class=tblHeaderSpace] {
                                display: none !important;
                            }
                            table[class=tblHeaderLinks] {

                                width: 100% !important;
                            }

                            td[class=tdHeaderLinks] {
                                text-align: center !important;
                                width: 100% !important;
                                padding-right: 0px !important;
                            }
                            table[class=tblContent] {
                                width: 100% !important;
                            }
                            td[class=tdLine] {
                                padding: 10px 10px 10px 10px !important;
                            }
                            table[class=tblFooter] {
                                width: 100% !important;
                            }
                            span[class=noLink] {
                                text-decoration: none !important;
                                color: inherit !important;
                            }

                            span[class=nowrap] {
                                white-space:nowrap;
                            }

                            td[class=tdEmailBody] {
                                padding: 0px 0px 0px 0px !important;

                            }

                            td[class=tdHeadlineSpacing] {
                                padding: 20px 10px 0px 10px !important;

                            }
                            div[class=divSectionDesktop] {
                                display: none !important;
                            }
                            div[class=divSectionMobile] {
                                display:block !important;
                                font-size: 13px !important;
                                max-height: none !important;
                                line-height: 14px !important;
                                overflow: visible !important;
                            }

                            img[class=img-max]{
                              max-width: 100% !important;
                              width: 100% !important;
                              height:auto !important;
                            }

                            div[class=mobilecontent]{
                                display: block !important;
                                max-height: none !important;
                            }

                            div[class=mobile]{
                                display: block !important;
                                line-height: 1.5 !important;
                                max-height: none !important;
                            }

                            td[class=tdHeaderImages] {
                                display: none !important;
                            }


                            td[class=tdLMLogoMobile] {
                                margin: auto 0;
                            }

                            table[class=tblViewBenefits] {
                                padding-left: 10px !important;
                            }

                            table[class=tblTopLMLinks] {
                                width: 100% !important;
                                text-align: center !important;

                                }   

                            table[class=tblTopPolicyInfo] {
                                width: 100% !important;
                                text-align: left !important;
                                }
                        }
                    .auto-style1 {
                        color: #616265;
                    }
                    </style>
                    </head>

                    <body bgcolor="#f6f4f5" >
                    <table width="100%" bgcolor="#f6f4f5" class="tblEmail" cellpadding="0" cellspacing="0" >
                        <tr>
                            <td class="tdHeader">
                                <table width="600" align="center" cellpadding="0" cellspacing="0" class="tblHeader">
                                    <tr>
                                        <td class="tdPreHeader">
                                            <table width="30%" height="30" align="left" style="float:left" cellpadding="0" cellspacing="0" class="tblPreHeaderText">
                                                <tr>
                                                    <td align="center" font="Arial" style="font-family: Arial, Helvetica, sans-serif; font-size:1px; color:#f6f4f5" class="tdPreHeaderText">
                                                        See what your loyalty can earn you.
                                                    </td> <!-- tdPreHeaderText -->
                                                </tr>
                                            </table> <!--tblPreHeaderText -->
                                            <table width="40%" height="30" align="left" style="float: left" cellpadding="0" cellspacing="0" class="tblPreHeaderLinks">
                                                <tr>
                                                    <td align="center" font="Arial" style="font-family: Arial, Helvetica, sans-serif; font-size:10px; color:#616265" class="tdPreHeaderLinks">
                                                        <a href="%%view_email_url%%" target="_blank" alias="View in Browser" style="color:#616265; text-decoration:none">
                                                    <strong style="color: #616265; font-weight:normal;text-decoration:none">View in Browser</strong></a>  |  
                                                        <a href="%%unsub_center_url%%" alias="Unsubscribe" style="color:#616265; text-decoration:none">
                                                            <strong style="color: #616265; font-weight:normal">Unsubscribe</strong></a>
                                                    </td> <!-- tdPreHeaderLinks -->
                                                </tr>
                                            </table>  <!-- tblPreHeaderLinks -->
                                            <table width="30%" height="30" cellpadding="0" cellspacing="0" class="tblPreHeaderSpace" align="right" style="float: right">
                                                <tr>
                                                    <td>&nbsp;</td>
                                                </tr>
                                            </table> <!-- tblPreHeaderSpace -->
                                        </td>
                                    </tr>
                                    <tr>

                                        <td bgcolor="#ffffff"> 
                                            <!--[if !mso 9]><!-->
                                            <div  class="mobilecontent" style="margin:0 auto; mso-hide:all;display:none;max-height:0px;overflow:hidden;">
                                                <table cellspacing="0" cellpadding="0" align="center">
                                                    <tr>
                                                        <td align="center" font="Arial" style="padding-top:20px;font-family: Arial, Helvetica, sans-serif; font-size:10px; color:#616265" class="tdPreHeaderLinks">
                                                            <a href="%%view_email_url%%" target="_blank" alias="View in Browser" style="color:#616265; text-decoration:none">
                                                        <strong style="color: #616265; font-weight:normal;text-decoration:none">View in Browser</strong></a>  |  
                                                            <a href="%%unsub_center_url%%" alias="Unsubscribe" style="color:#616265; text-decoration:none">
                                                                <strong style="color: #616265; font-weight:normal">Unsubscribe</strong></a>
                                                        </td> 
                                                    </tr>
                                                    <tr>
                                                        <td style="padding: 0 0 0 0" class="tdLMLogoMobile" valign="bottom">
                                                            <a href="%%=RedirectTo(@urlLMCOM)=%%" target="_blank">
                                                                <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/Logo_LMI.jpg" border="0" height="63" width="220" style="display:block" />
                                                            </a>
                                                        </td>  
                                                    </tr>   
                                                </table>
                                            </div>
                                            <!--<![endif]-->    
                                        </td> 

                                    </tr>
                                    <tr>
                                        <td bgcolor="#ffffff" class="tdHeaderImages">
                                            <table width="100%" cellspacing="0" cellpadding="0" align="center" class="tblHeaderImages">
                                                <tr>
                                                    <td width="50%" style="padding: 0 0 0 30px" class="tdLMLogo" valign="bottom">
                                                        <a href="%%=RedirectTo(@urlLMCOM)=%%" target="_blank">
                                                            <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/Logo_LMI.jpg" border="0" height="63" width="220" style="display:block" class="imgLogo" />
                                                        </a>
                                                    </td>  <!-- tdLMLogo -->
                                                    <td width="50%" align="right" class="tdMedallion">
                                                        <a href="%%=RedirectTo(@urlMedallion)=%%" target="_blank">
                                                            <span class="swMedallion">
                                                                <img src="http://image.email-libertymutual.com/lib/fe6a15707464047f7c1c/m/1/medallionDesktop.jpg" alt="See Insurance in a Whole New Light" border="0" class="imgMedallion" />
                                                            </span>
                                                        </a>
                                                    </td> <!-- tdMedallion -->
                                                </tr>
                                            </table>
                                        </td> <!-- tdHeaderImages -->
                                    </tr>
                                    <tr>
                                        <td bgcolor="#ffffff" class="tdHeaderText">
                                            <table class="tblTopLMLinks" width="300" align="right" style="float:right;border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0;" cellpadding="0" cellspacing="0" border="0">

                                                <tr>
                                                    <td align="right" font="Arial" style="padding-right: 20px; padding-top:15px;padding-bottom: 10px; font-family : Arial, Helvetica, sans-serif; font-size:13px; color:#616265; line-height:18px" class="tdHeaderLinks">
                                                        <a href="%%=RedirectTo(@urlLMCOM)=%%" target="_blank" style="color:#616265"><strong style="color: #616265; font-weight:normal">LibertyMutual.com</strong></a>  |  
                                                        <a href="%%=RedirectTo(@urlMyAccount)=%%" target="_blank" style="color:#616265"><strong style="color: #616265; font-weight:normal">My Account</strong></a>
                                                    </td> <!-- tdHeaderLinks -->
                                                </tr>

                                            </table> <!-- tblTopCTA -->
                                            <table class="tblTopPolicyInfo" align="left" style="float:left;border-collapse: collapse; mso-table-lspace: 0; mso-table-rspace: 0;" width="300" cellpadding="0" cellspacing="0" border="0">

                                                <tr>
                                                    <td style="color:#616265;font-family : Arial, Helvetica, sans-serif;font-size:13px;line-height:18px;padding-left:15px;padding-top:15px">
                                                        <b>Policy Number:</b> %%POLICY_NUMBER%% <br />
                                                        <b>Customer Since:</b> %%PolicyEffectiveDate%%
                                                    </td>
                                                </tr>
                                            </table>

                                        </td> <!-- tdHeaderText -->
                                    </tr>
                                </table> <!-- tblHeader -->
                            </td> <!-- tdHeader --> 
                        </tr>



                    </table> <!-- tblEmail -->
                    </body>

                    </html>

全名可能意味着名字,这就是您的代码无效的原因。