View Full Version : help help help - PHP connect to Database
bobbi_gold
03-23-2006, 02:39 AM
Please tell me the PHP-code to connect to SQL-server database:confused:
chump2877
03-23-2006, 03:53 AM
http://us2.php.net/manual/en/function.mysql-connect.php
http://us2.php.net/manual/en/function.mysql-select-db.php
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Not connected : ' . mysql_error());
}
// make foo the current db
$db_selected = mysql_select_db('foo', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>
This is assuming you are using MySQL...
Mhtml
03-23-2006, 04:37 AM
This is assuming you are using MySQL...
Umm....
SQL-server
A little too hasty in your response, perhaps?
Connections to a SQL Server can be done as such:
$conn = @mssql_connect("server","username","password") or die(mssql_get_last_message());
bobbi_gold
03-24-2006, 03:50 AM
thanks! :thumbsup:
But how to excute the a string query? with SQL-SEVER
Nightfire
03-24-2006, 04:33 AM
The php manual will show you :) http://uk2.php.net/function.mssql-query
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.