budimir Posted May 19, 2012 Share Posted May 19, 2012 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??? Quote Link to comment https://forums.phpfreaks.com/topic/262786-select-query-not-working/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 19, 2012 Share Posted May 19, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/262786-select-query-not-working/#findComment-1346882 Share on other sites More sharing options...
budimir Posted May 19, 2012 Author Share Posted May 19, 2012 That was it! You really are a guru!!! thank you so much... I was trying different stuff for two hours and didn't see that... Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/262786-select-query-not-working/#findComment-1346883 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.