Jump to content

SELECT query not working???


budimir

Recommended Posts

Hi Guys,

 

I upgraded to PHP 5.3.10 and use MSSQl Server 2008. I have everything working. Worked my butt out to connect to the server, but now I have a problem with a single query that is killing me!!!! please help me.

 

My peace of code is

try{
$conn = new PDO ("sqlsrv:server=server3\server3; database=XXXXXX", "XXXXX", "XXXXXXX");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch (PDOException $e) {
    echo "<br />" . $e->getMessage() . "\n";
    exit;
  }

//Učitavanje korisnika iz EIS baze (Opći podaci)
echo "<p>Sikronizacija korisnika između NAV <------> WebShop</p>";
echo "1. Učitavanje korisnika iz EIS baze - Opći podaci<br />";

$upit = "SELECT * FROM UserTable";
$params = array();
$options =  array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$query = sqlsrv_query($conn,$upit,$params,$options) or die (sqlsrv_errors());
$broj = sqlsrv_num_rows($query);

 

the error I'm getting is

 

Warning: sqlsrv_query() expects parameter 1 to be resource, object given in C:\inetpub\wwwroot\drezga_webshop\sync\sync_users.php on line 23 Array

 

can you tell me what I'm doing wrong???

Link to post
Share on other sites

You are using the PDO extension (based on the connection code you posted.) You would use PDO methods and properties for executing queries and retrieving data, not sqlsrv_ statements.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.