April 2026
Intermediate
1009 pages
34h 15m
English
The chapter concludes with the obligatory guestbook example. The same advice we gave in the previous chapters applies here, as well: set the authorizations correctly and adjust the parameters of sqlsrv_connect() if necessary.
To create the table, it is best to send the associated statement directly to the database using sqlsrv_query(). Alternatively, you can also use the Management Studio or a comparable tool.
<?php if ($db = sqlsrv_connect( "(local)\\SQLEXPRESS", ["Database" => "PHP"])) { $sql = "CREATE TABLE guestbook ( id INT IDENTITY NOT NULL, heading VARCHAR(1000), entry VARCHAR(5000), author VARCHAR(50), email VARCHAR(100), date DATETIME, PRIMARY KEY (id) )"; if (sqlsrv_query($db, ...
Read now
Unlock full access