RE: [PHP] Connecting to MSSQL Using PHP on Apache 2.X.X Windows Machine
| From: | Jay Blanchard | Date: | Wed, 18 Jun 2003 14:51:03 +0000 |
| Subject: | RE: [PHP] Connecting to MSSQL Using PHP on Apache 2.X.X Windows Machine | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-151987@lists.php.net to get a copy of this message | ||
[snip]
<?php
$myServer = "192.92.0.248";
$myUser = "repro";
$myPass = "repro";
$myDB = "repro";
print ("Attempting to connect to MSSQL - <br>");
$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
print ("stage2");
$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");
#this is the create bit
print ("Connected trying to send the query!<br>");
$query = "CREATE TABLE customer (id bigint NULL, cus_name char(100)
NULL, address1 char(100) NULL, address2 char(100) NULL, town char(50)
NULL, county char(50) NULL, postcode char(30) NULL, tel char(30) NULL,
fax char(30) NULL, mobile char(30) NULL, email char(50) NULL, notes
char(250) NULL)"
or die("Creating table failed");
$result = mssql_query($query);
print ("Tables Created");
?>
[/snip]
See anything wrong here...
$s = @mssql_connect($myServer, $myUser, $myPass)
$d = @mssql_select_db($myDB, $s)
??? Remove the '@' signs and you should go just fine if your user has
permissions to create tables;
HTH!
Jay