Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can somebody help me connect to SQL Server?

Status
Not open for further replies.

majorbroncosfan

Programmer
Feb 23, 2001
121
US
I have been extremely successful using ASP and MS-SQL for a long time, but am having difficulty making a transition to PHP. I've tried to connect, but have been unsuccessful. The ASP version of my page goes like this:

db.open "Provider=SQLOLEDB;User Id=user;Password=password; Initial Catalog=database;Data Source=DATABASESERVER\SQLSERVER;"

The PHP version I've used goes like this:

<?
$db_name = &quot;intranet&quot;;

$table_name = &quot;tester&quot;;

$connection = @mssql_connect(&quot;DATABASESERVER\SQLSERVER&quot;, &quot;userid&quot;, &quot;password&quot;) or die(&quot;Couldn't connect&quot;);

$db = @mssql_select_db($db_name, $connection) or die(&quot;Couldn't select database.&quot;);

$sql = &quot;INSERT INTO $table_name (testID, testName) VALUES (\&quot;1234\&quot;, \&quot;Jeff\&quot;)&quot;;

$result = @mssql_query($sql, $connection) or die(&quot;Couldn't execute query&quot;);
?>

Please help!
 
the correct DSN string to connect to SQL Server is:
&quot;Driver = {SQL Server};server = {server name};uid={user};pwd={...};database={database name};&quot; Ion Filipski
1c.bmp


filipski@excite.com
 
and for strings in working with SQL Server use single quotas('), not double(&quot;), for numbers quotas are not required however they work. Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top