SQL SERVER - Can't apply changes to database
| From: | Emerson Donizeti Batista | Date: | Fri, 11 Apr 2003 02:38:49 +0000 |
| Subject: | SQL SERVER - Can't apply changes to database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143428@lists.php.net to get a copy of this message | ||
Hi everybody,
I'm using (for test purposes) Windows 98 / Apache 1.3.14 / PHP 4.3.1 / SQL SERVER 7.0
The script below makes a change on the the Northwind Database. This is the sequence:
1 - UPDATE Employees table
2 - SELECT Employees table
3- SHOW the results
When I run the script, the SELECT part shows that my update was ok.
But If I call the php script again, my changes were not saved. If I use query analyzer, I make
changes normally. The SQL Profiler registers the instructions... but no change is applied to my
database.
What's wrong?
Thks
Emerson.
<?php
$myServer = "localhost";
$myUser = "sa";
$myPass = "";
$myDB = "Northwind";
$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");
$result = mssql_query("UPDATE Employees SET FirstName = 'Glenda' WHERE FirstName =
'Laura'");
echo mssql_get_last_message();
$query = "SELECT TitleOfCourtesy+' '+FirstName+' '+LastName AS Employee
";
$query .= "FROM Employees ";
$query .= "WHERE Country='USA' AND Left(HomePhone, 5) = '(206)'";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" :
"s") . " Returned </h1>";
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Employee"] . "</li>";
}
?>