Hi everyone,
 
I am trying to connect to MSSQL and create a table in a database using
PHP.
 
Here is my code:
 
<?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");
 
?>
 
When viewing the page I only get the first print line displayed in the
browser. When I check MSSQL no table has been added. Does anyone know
how I can fix this? I am running Apache 2.X.X on Windows 2000 Server (on
my local machine) using PHP 4.X.X.
 
Any help is appreciated
 
Gary Ogilvie

Reply via email to