使用PHP的PDO很难将值插入到mysql中

时间:2015-06-17 21:38:39

标签: php mysql database pdo

我很难将数据插入到我的数据库中,我创建了所有字段并确保拼写正确,我还确保所有值都在我尝试插入数据库的变量名中,I我不确定我做错了什么,这是我的代码。

数据库脚本

//This script provides connection to the database//
//Connect
$user="root";
$pass="";
try {
    $connection = new PDO('mysql:host=localhost;dbname=forms', $user, $pass);
} catch (Exception $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
die();
}

将数据插入数据库脚本

try {
        //Prepare
        $prepIt = $connection->prepare(
        "INSERT INTO `formdata`(`revision`, `printOnly`, `artOnly`, `sales`, `service`, `fBoth`, `clientRep`, `dealerName`, `clientContact`, `clientCell`, `clientEmail`, `orderDate`, `jobName`, `coOp`, `dateDrop1`, `dateDrop2`, `qty1`, `qty2`, `dateDrop1Exp`, `dateDrop2Exp`, `jobDesc`, `otherDesc`, `envelopes`, `otherEnvelope`, `scratcher`, `fInsert`, `fKey`, `kbbAppend`, `matchJob`, `4x6Note`, `postItNote`, `creditCard`, `busCard`, `bbAppend`, `font`, `fReal`, `preSort1Class`, `firstClassStamp`, `preSortStandard`, `canceledStamp`, `databaseEquity`, `dataDatabase`, `dataBk`, `dataCredit`, `dataOsBrand`, `dataOsNoBrand`, `dataSaturation`, `dataOther`, `dGiveaway`, `genGiveaway`, `inQuant1`, `inQuant2`, `inQuant3`, `inQuant4`, `inDesc1`, `inDesc2`, `inDesc3`, `inDesc4`, `inPricePc1`, `inPricePc2`, `inPricePc3`, `inPricePc4`, `total1`, `total2`, `total3`, `total4`, `recQuant1`, `recQuant2`, `recQuant3`, `recDesc1`, `recDesc2`, `recDesc3`, `recPerRecord1`, `recPerRecord2`, `recPerRecord3`, `recListTotal1`, `recListTotal2`, `recListTotal3`, `formComments`) VALUES ($revision, $printOnly, $artOnly, $sales, $service, $both, $clientRep, $dealerName, $clientContact, $clientCell, $clientEmail, $orderDate, $jobName, $coOp, $dateDrop1, 
            $dateDrop2, $qty1, $qty2, $dateDrop1Exp, $dateDrop2Exp, $jobDesc, $otherDesc, $envelopes, $otherEnvelope, $scratcher, $insert, $key, $kbbAppend, $matchJob, $_4x6Note, $postItNote, $creditCard, $busCard,
            $bbAppend, $font, $real, $preSort1Class, $firstClassStamp, $preSortStandard, $canceledStamp, $databaseEquity, $dataDatabase, $dataBk, $dataCredit, $dataOsBrand, $dataOsNoBrand, $dataSaturation, $dataOther,
            $dealerGiveaway, $genericGiveaway, $inQuant1, $inQuant2, $inQuant3, $inQuant4, $inDesc1, $inDesc2, $inDesc3, $inDesc4, $inPricePc1, $inPricePc2, $inPricePc3, $inPricePc4, $total1, $total2, $total3, $total4,
            $recQuant1, $recQuant2, $recQuant3, $recDesc1, $recDesc2, $recDesc3, $recPerRecord1, $recPerRecord2, $recPerRecord3, $recListTotal1, $recListTotal2,$recListTotal3, $comments)");
            //Execute
            $prepIt->execute();
            //Confirmation
            echo "Job Has Been Created";

    } catch (Exception $e) {
        //Catch any errors
        echo "there was an error.".$e->getMessage();
    }

0 个答案:

没有答案