Jump to content

Brian Swan

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by Brian Swan

  1. I think that, by default, PHP uses file-based session data (i.e. it stores session info in files), so restarting IIS does not lose session data. Hope that helps. -Brian
  2. Yes, WPI is updated often. I know that are plans to add PHP 5.3 as an option soon, but I don't have any dates. Glad the information was helpful. -Brian
  3. jjmac- If you are moving to PHP5, I would suggest that you bite the bullet (as tough as it might be) and move to the sqlsrv driver (the SQL Server Driver for PHP). The old mssql driver is based on obsolete dblib technology (more about that here: http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx). The good news is that the 2.0 release of the sqlsrv driver comes in two flavors: the SQLSRV driver (which is a "function-based" or "procedural" driver) and the PDO_SQLSRV driver (which supports PDO and is object-oriented). So, you shouldn't have to make the jump to using classes if you don't want to. The bad news is that there isn't an easy way (that I know of) to install PHP 5 with support for the old php_mssql.dll driver. Hopefully, this blog post will help convert to the sqlsrv driver: http://blogs.msdn.com/b/brian_swan/archive/2010/03/10/mssql-vs-sqlsrv-what-s-the-difference-part-2.aspx. On the question of CGI vs. Fast-CGI, definitely go with Fast-CGI (the CGI module spins up a new PHP process for every incoming request!). Performance with Fast-CGI is much better. One easy way to get this all set up is to use the Web Platform Installer (installs PHP, sqlsrv driver, SQL Server Express, etc...and configures everything). Check it out here: http://www.microsoft.com/web/downloads/platform.aspx. One drawback of the WPI is that it installs PHP 5.2.14, not PHP 5.3 (which has tons of Windows optimizations). The question of VC6 vs VC9 only comes into play (I think) if you are running PHP 5.3...in which case you should go for VC9. If you want to go with PHP 5.3, you'll have to install/configure it manually: http://php.net/manual/pl/install.windows.iis7.php. I hope that helps. Let me know if you have more questions. -Brian
  4. Heh...I was in the posting this reply just as you posted... I'm not sure I understand the scenario correctly, but I'll suggest code that is structured like this: if ($listoption == ALL) { Execute "SELECT * FROM details" } else { Execute "SELECT * FROM details WHERE otype = $listoption" } If that's not what you are looking for, post your relevant PHP code and describe in a bit more detail what isn't working...I'll look again. As a side note, I would avoid code that concatenates SQL with user input (but maybe you're just writing abbreviated code like I am and you're using parameterized queries in your real code). I have a blog post on this topic: http://blogs.msdn.com/b/brian_swan/archive/2010/03/04/what_2700_s-the-right-way-to-avoid-sql-injection-in-php-scripts_3f00_.aspx -Brian
  5. Can you provide a bit more detail? i.e. Is this error occuring when you try to execute a PHP script? If yes, what is the script? Any detail that might help us look in the right direction would be great. Thanks. -Brian
  6. I think your query is returning 2 result sets: one for the "USE database" statement, and one for the "SELECT ..." statement. The first result set has no fields (obviously). Try calling sqlsrv_next_result($stmt) after you execute the query and before you start iterating through rows. Let me know how that works. -Brian
  7. What is the query that you are executing? If it is an INSERT, UPDATE, or DELETE query, try calling sqlsrv_rows_affected (instead of sqlsrv_fetch). -Brian
  8. Cool...glad you have things working. Am I right in reading that you connected with the php_sqlsrv.dll driver (not the php_mssql.dll driver)? Just curious. Thanks. -Brian
  9. Have you configured SQL Server to allow remote connections? If you have, can you get more detailed error info? BTW, since you are running PHP on Windows, I'd suggest you use the Microsoft-built driver (available here: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9 , or via the Web Platform Installer: http://www.microsoft.com/web/downloads/platform.aspx ). It does not rely on the depricated DBLib technology. If you are interested, more info here: http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx and http://blogs.msdn.com/b/brian_swan/archive/2010/03/10/mssql-vs-sqlsrv-what-s-the-difference-part-2.aspx. -Brian
  10. Since you are running on Windows, I'd suggest you use the driver that is produced by Microsoft (the sqlsrv driver). You can download the sqlsrv driver here: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=ccdf728b-1ea0-48a8-a84a-5052214caad9. This video will show you how to install it: . This topic in the documentation shows you how to call a stored procedure: http://msdn.microsoft.com/en-us/library/cc296167(SQL.90).aspx If you are interested int the difference between the sqlsrv and mssql drivers, there are some topics here: http://blogs.msdn.com/brian_swan/archive/tags/mssql+driver/default.aspx Hope that helps. -Brian
  11. OH! This might come in handy too: http://blogs.msdn.com/brian_swan/archive/2010/02/10/sql-server-driver-for-php-understanding-windows-authentication.aspx Hope that helps. -Brian
  12. Ah...I see. You can use any version of SQL Server...I just used SQL Express becuase I figured most folks would be interested in the free version. It sounds to me like you should be able to use Windows Authentication in your scenario. More info here: http://msdn.microsoft.com/en-us/library/cc296198(SQL.90).aspx
  13. Not sure I understand your last question. If you install the sqlsrv driver just like you would any other PHP extension (put the .dll in the extension directory, add extension=php_sqlsrv.dll to your php.ini file, then restart your web server), the driver should be loaded and ready to use. Is that what you were asking? -Brian
  14. You might want to consider using the PHP driver (sqlsrv) released by Microsoft. There is more information about the difference between the mssql and the sqlsrv divers here: http://blogs.msdn.com/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx. If you choose to go that route, this might be helpful for getting set up: http://blogs.msdn.com/brian_swan/archive/2010/02/08/getting-started-with-the-sql-server-driver-for-php.aspx. To your last question, you shouldn't have any problems with the web server and database server being on different machines as long as your database server is configured to allow remote connections. Hope that helps. -Brian
  15. That query looks like it should give you the results you are looking for. Is it not?
  16. Bindi- I wrote a blog post about backing up a SQL Server Database from PHP: http://blogs.msdn.com/brian_swan/archive/2010/04/06/backup-and-restore-with-the-sql-server-driver-for-php.aspx This might not be exactly what you are looking for, but it might help. If it isn't helpful, let me know and I'll see what I can do. Thanks. -Brian
  17. I could be totally wrong here, but isn't this line a problem? $_POST['Depart_ID'] = (int)$Depart_ID; Don't you want this? $Depart_ID = $_POST['Depart_ID']; -Brian
  18. Yes, I've tested it and it works. Can you share both the stored procedure definition and the PHP code that calls it? (Or some sproc/php code that reproduces the issue?) I'll look into it further.
  19. Although the recommended way to execute store procedures witht the sqlsrv driver is to use the "call" syntax, you can use the EXEC syntax. So if your stored procerdure declares a default value for a param, like for @test here: CREATE PROCEDURE GetEmployeeSalesYTD @SalesPerson nvarchar(50), @test nvarchar(50) = null, @SalesYTD money OUTPUT AS SELECT @SalesYTD = SalesYTD FROM Sales.SalesPerson AS sp JOIN HumanResources.vEmployee AS e ON e.BusinessEntityID = sp.BusinessEntityID WHERE LastName = @SalesPerson ...then you shoul be able to do this... $tsql_callSP = "EXEC GetEmployeeSalesYTD @SalesPerson=?, @SalesYTD=?"; $lastName = "Blythe"; $salesYTD = 0.0; $params = array( array($lastName, SQLSRV_PARAM_IN), array($salesYTD, SQLSRV_PARAM_OUT) ); /* Execute the query. */ $stmt3 = sqlsrv_query( $conn, $tsql_callSP, $params); if( $stmt3 === false ) { echo "Error in executing statement 3.\n"; die( print_r( sqlsrv_errors(), true)); } /* Display the value of the output parameter $salesYTD. */ echo "YTD sales for ".$lastName." are ". $salesYTD. "."; Does that help?
  20. I'm wondering if this topic (How to: Retrieve Output Parameters) in the sqlsrv documentation might help: http://msdn.microsoft.com/en-us/library/cc626303(SQL.90).aspx -Brian
  21. I think all the .msi does is to lay down the .mdf and .ldf files. You still have to attach the database after that. If you have SQL Server Management Studio, here are instructions for attaching a database: http://msdn.microsoft.com/en-us/library/ms190209.aspx Hope that helps. -Brian
  22. I’m a part of the team working on the Microsoft SQL Server 2005 Driver for PHP. I want to let people know about the release today of our first Community Technology Preview. We are excited about this release largely because it gives us the opportunity to receive feedback from the PHP community. We continue to work hard toward developing this driver, but want to do so with the benefit of your comments and insight. The bits and documentation can be downloaded here: http://www.microsoft.com/downloads/details.aspx?FamilyId=85F99A70-5DF5-4558-991F-8AEE8506833C&displaylang=en. Visit our team blog to provide feedback: http://blogs.msdn.com/sqlphp. For peer-to-peer support, visit the SQL Server Data Access Forum: http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=87&SiteID=1. Thanks. Brian Swan Programming Writer Microsoft
×
×
  • 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.