Re: SQL SERVER - Can't apply changes to database
| From: | Emerson Donizeti Batista | Date: | Fri, 11 Apr 2003 03:00:34 +0000 |
| Subject: | Re: SQL SERVER - Can't apply changes to database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143432@lists.php.net to get a copy of this message | ||
I've tried with no effect:
mssql_query("BEGIN TRANSACTION")
....
...
mssql_query("COMMIT TRANSACTION")
[]s
Emerson
-----Mensagem Original-----
De: "James Katarski" <j.katarski@ecu.edu.au>
Para: <php-general@lists.php.net>
Enviada em: Quinta-feira, 10 de Abril de 2003 23:41
Assunto: Re: [PHP] SQL SERVER - Can't apply changes to database
> Emerson,
>
> Does the database require a commit?
>
> Cheers,
>
> James.
>
> >>> "Emerson Donizeti Batista" <emebatista@microsiga.com.br> 04/11/03
> 10:38AM >>>
> 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>";
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php