$mssql = odbc_connect( and odbc_exec code

Newbie Spellweaver
Joined
Jan 22, 2009
Messages
44
Reaction score
1
hi i am having problems with $mssql = odbc_connect(
and odbc_exec can anyone help i cant seem to get them to work
 
we just need the codes for mssql+odbc_connect with pdo and odbc_exe to see the data

$cnx = new PDO("odbc:Driver={EFR};Server=localhost;Port:7004;Database=EFR", 'LcLfVJFLTKTCEHRO', '*'); –
 
new PDO('odbc:Driver={SQL Server Native Client 10};Server='.SQL_HOST.';Database='.SQL_WEB_DB.'', SQL_USER, SQL_PASSWORD)
 
new PDO('odbc:Driver={SQL Server Native Client 10};Server='.SQL_HOST.';Database='.SQL_WEB_DB.'', SQL_USER, SQL_PASSWORD)

the "new PDO('odbc:Driver={SQL Server Native Client 10};Server='.SQL_HOST.';Database='.SQL_WEB_DB.'', SQL_USER, SQL_PASSWORD)" is added on the code. but the global odbc_exec is lacking.
 
the "new PDO('odbc:Driver={SQL Server Native Client 10};Server='.SQL_HOST.';Database='.SQL_WEB_DB.'', SQL_USER, SQL_PASSWORD)" is added on the code. but the global odbc_exec is lacking.
provide full code, is there any reason you uses odbc connection? that's should be like the last choice for you to do...
 
Are the correct PHP extensions enabled to allow this ?
 
provide full code, is there any reason you uses odbc connection? that's should be like the last choice for you to do...


define("Username", 'sa');
define("Passowrd", 'dbpassword');
define("DSN", 'odbc:Driver={SQL Server};server=SERVERNAME\SQLEXPRESS');
try {
$mssql = new PDO("odbc:Driver={SQL Server};server=SERVERNAME\SQLEXPRESS;DATABASE=account_dbf", Username, Passowrd);
}
catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
$query = "SELECT account, FROM ACCOUNT_DBF.dbo.ACCOUNT_TBL";
$stmt = $mssql->prepare($query);
$stmt->execute();
 
define("Username", 'sa');
define("Passowrd", 'dbpassword');
define("DSN", 'odbc:Driver={SQL Server};server=SERVERNAME\SQLEXPRESS');
try {
$mssql = new PDO("odbc:Driver={SQL Server};server=SERVERNAME\SQLEXPRESS;DATABASE=account_dbf", Username, Passowrd);
}
catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
$query = "SELECT account, FROM ACCOUNT_DBF.dbo.ACCOUNT_TBL";
$stmt = $mssql->prepare($query);
$stmt->execute();
And what is the exact error you get?
 
it is fixed now thanks for you help
we have to figure it out now theses are the codes php.pdo
define("Username", 'sa');
define("Passowrd", 'dbpassword');
define("DSN", 'odbc:Driver={SQL Server};server=SERVERNAME\SQLEXPRESS');
try {
$mssql = new PDO("odbc:Driver={SQL Server};server=SERVERNAME\SQLEXPRESS;DATABASE=account_dbf", Username, Passowrd);
}
catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
$query = "SELECT account, FROM ACCOUNT_DBF.dbo.ACCOUNT_TBL";
$stmt = $mssql->prepare($query);
$stmt->execute();
 
Back