rgb192
asked on
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]:
i am using windows server 2008, iis7, sqlserver 2005, php 5.2.6
begin
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 229 [Microsoft][SQL Native Client][SQL Server]The SELECT permission was denied on the object 'payments', database 'ow1222', schema 'dbo'. (SQLExecute[229] at ext\pdo_odbc\odbc_stmt.c:1 33)' in C:\inetpub\wwwroot\missing 4.php:25 Stack trace: #0 C:\inetpub\wwwroot\missing 4.php(25): PDOStatement->execute() #1 C:\inetpub\wwwroot\missing 4.php(39): dbfetcharray('??select * from...') #2 {main} thrown in C:\inetpub\wwwroot\missing 4.php on line 25
begin
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 229 [Microsoft][SQL Native Client][SQL Server]The SELECT permission was denied on the object 'payments', database 'ow1222', schema 'dbo'. (SQLExecute[229] at ext\pdo_odbc\odbc_stmt.c:1
<?php
$db = new PDO("odbc:Driver={SQL Native Client};Server=$ip;Database=$database;dbname=$database",$user,$pass);
function dbfetcharray($sql) {
global $db;
//try {
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$rs = $db->prepare($sql);
$rs->execute();
//recordSQLError("a1",$sql,"");
return $rs->fetchAll();
//}
//catch(PDOException $e) {
//recordSQLError("dbfetcharray",$sql,$e->getMessage());
//}
}
echo '<br>begin';
$sql="
select * from payments
";
$payments=dbfetcharray($sql);
foreach($payments as $p){
echo $p['orderid'];
}//end foreach
echo '<br>end';
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i changed the code to echo the error.
I have a similar question
https://www.experts-exchange.com/questions/26946297/The-SELECT-permission-was-denied-on-the-object-'payments'-database-'database'.html
I have a similar question
https://www.experts-exchange.com/questions/26946297/The-SELECT-permission-was-denied-on-the-object-'payments'-database-'database'.html
ASKER
this code worked on another windows server