请在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
答案 0 :(得分:1)
您尚未定义连接字符串中使用的变量$HDFCSDM
(变量在双引号字符串中展开)。如果你先定义它,那么你不应该得到错误:
$HDFCSDM = "C:\\file.mdb";
try{
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$HDFCSDM", "", "");
}
答案 1 :(得分:0)
进行DSN连接时:
$db_connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\DataDir\DB_NAME.mdb;DefaultDir=C:\DataDir";
您的DBQ参数指向数据库。我没有看到这种情况发生。您需要在代码或此声明中更早地定义它。