Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

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:133)' in C:\inetpub\wwwroot\missing4.php:25 Stack trace: #0 C:\inetpub\wwwroot\missing4.php(25): PDOStatement->execute() #1 C:\inetpub\wwwroot\missing4.php(39): dbfetcharray('??select * from...') #2 {main} thrown in C:\inetpub\wwwroot\missing4.php on line 25

<?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';
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

is obdc working on windows server

this code worked on another windows server