Jump to content

DB Connection OK but not mssql_query


boubaboubaa

Recommended Posts

I'm new to MSSQL and SQLEXPRESS, had hoped it would work as easily as MYSQL.

 

Having problems with mssql_query.

 

The following test script connects and opens database, but will not create a table.  Is it possible that the connection is broken for some reason?

 

<?php

$myServer = "AESERVICES\SQLEXPRESS,1033";

$myUser = "user";

$myPass = "password";

$myDB = "dbName";

 

//connection to the database

$dbhandle = mssql_connect($myServer, $myUser, $myPass)

  or die("Couldn't connect to SQL Server on $myServer");

 

//select a database to work with

$selected = mssql_select_db($myDB, $dbhandle)

  or die("Couldn't open database $myDB");

 

if ($selected == true){

 

echo "database open";

}

 

$tablecreate = "CREATE TABLE members (

id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,

name VARCHAR(10) NOT NULL DEFAULT '',

year VARCHAR(4) NOT NULL DEFAULT ''

)";

echo $tablecreate;

 

$result = mssql_query($tablecreate) or die ("Error in query");

 

...

?>

 

Any one have any ideas?

 

 

Link to comment
https://forums.phpfreaks.com/topic/95883-db-connection-ok-but-not-mssql_query/
Share on other sites

  • 2 weeks later...

why are you using the connector with variables?

 

Can't you do it without it that way? I mean just place the name, just place your account and just place your password in the connector, instead of defening it, the way you are doing now.

 

I mean it's php, not javascript, so you don't have to define the variables.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.