PDO trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dapperdanman1400
Forum Newbie
Posts: 1
Joined: Mon Nov 19, 2007 10:33 am

PDO trouble

Post by dapperdanman1400 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi, I'm trying to start working with the PDO object class for database use.  I'm using MSSQL as my database.

The problem is when I use the SQL wildcard (*), it returns zero rows as results.  However, when I specify a specific column, it outputs results just fine.  What could I be missing?  Code below:

Code: Select all

<?php

try {
  $dbh = new PDO('mssql:host=localhost;dbname=test_db', 'db_name', 'notarealpassword');
  foreach ($dbh->query('SELECT * FROM test_table') as $row) {
      print_r($row);
   }
   $dbh = null;
  
}
catch (PDOException $e) {
   die('<span style="font-style: bold;">Error:</span> '.$e->getMessage());
}

?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

can you try adodb

Post by yacahuma »

can you try adodb. The syntax is almost identical. I am curious if you get the same results.
http://adodb.sourceforge.net/
Post Reply