0

请帮助 php

<?php
include("../../php-form-builder-class/class.form.php");
$form = new form("HDFC_SDM");
session_start();
$form->setAttributes(array(    
    "width" => 400
));
$form->addTextbox("SRNO  :","SrNo","");
$form->addTextbox("First Name  :","FName","");
$form->addTextbox("Middle Name :","MName","");
$form->addTextbox("Last Name   :","LName","");
$form->addTextbox("Address L1  :","AddL1","");
$form->addTextbox("Address L2  :","AddL2","");
$form->addTextbox("Address L3  :","AddL3","");
$form->addTextbox("City        :","City","");
$form->addTextbox("State       :","State","");
$form->addTextbox("Telephone   :","TFone","");
$form->addTextbox("Mobile      :","MFone","");
$form->addTextbox("Status      :","Statu","");
$form->addTextbox("Notes       :","Notes","");
$form->addRadio("Address Proof :","AProof","",array("1" => "Ration Card", "2" => "Electricity Bill", "3" => "Election Card"));
$form->addFile("Address Proof Xerox", "AProofX");
$form->addRadio("Identity Proof :","IProof","",array("1" => "Pan Card", "2" => "Nationalize Bank Identity", "3" => "Election Card"));
$form->addFile("Identity Proof Xerox", "IProofX");
$form->addRadio("DOB Proof :","DProof","",array("1" => "Pan Card", "2" => "Form No. 9", "3" => "Election Card"));
$form->addFile("DOB Proof Xerox", "DProofX");
$form->addButton();
try{
    $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$HDFCSDM", "", "");
}
catch(PDOException $e){
    echo $e->getMessage();
}
$form->render();

?>

出现以下错误:

Undefined variable: 

HDFCSDM in C:\wamp\www\MY HDFC PROJECT\DEMO\helloworld.php on line 29
could not find driver
4

2 回答 2

1

您尚未定义$HDFCSDM连接字符串中使用的变量(变量在双引号字符串中展开)。如果你先定义它,那么你不应该得到错误:

$HDFCSDM = "C:\\file.mdb";
try{
    $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$HDFCSDM", "", "");
}
于 2012-10-01T15:28:05.683 回答
0

当您进行 DSN 连接时:

$db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\DataDir\DB_NAME.mdb;DefaultDir=C:\DataDir"; 

您的 DBQ 参数指向一个数据库。我不认为会发生这种情况。您需要在代码中或在此声明中更早地定义它。

于 2012-10-01T15:29:34.357 回答