|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Hello,
is there someone who can help me? I started with mysql - php connection (no problemo) but now i would like to connect to a ms sql database instead. Is there someone who can help me with this? <?php # Script 12.4 - mysql_connect.php // This file contains the database access information. This file also establishes a connection to MySQL and selects the database. // Set the database access information as constants. DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', ''); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'tz_base'); if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection. if (!mysql_select_db (DB_NAME)) { // If it can't select the database. // Handle the error. my_error_handler (mysql_errno(), 'Could not select the database: ' . mysql_error()); // Print a message to the user, include the footer, and kill the script. echo '<p><font color="red">The site is currently experiencing technical difficulties. We apologize for any inconvenience.</font></p>'; include_once ('includes/footer.html'); exit(); } // End of mysql_select_db IF. } else { // If it couldn't connect to MySQL. // Print a message to the user, include the footer, and kill the script. my_error_handler (mysql_errno(), 'Could not connect to the database: ' . mysql_error()); echo '<p><font color="red">The site is currently experiencing technical difficulties. We apologize for any inconvenience.</font></p>'; include_once ('includes/footer.html'); exit(); } // End of $dbc IF. // Function for escaping and trimming form data. function escape_data ($data) { global $dbc; if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } return mysql_real_escape_string (trim ($data), $dbc); } // End of escape_data() function. ?> But now: how to adapt to an ms sql database??? pleasssssse someone can help ??? |
|
#2
|
||||
|
||||
|
Okay, I tried this for a schoolproject and believe me... IT'S HARD!!!!
First of all, do you use Linux or Windows? When you use Windows, I don't have a clue, if you don't have your own server (on Linux) I don't know either... I manage to do this on a Debian Linux machine after installing A LOT of extra packages. If you can do the same with a MySQL-database, I suggest to use it. Even creating a very big database is less work than connecting Linux with Microsoft... Let me know! Cheers,
__________________
Work to live, don't live to work |
|
#3
|
|||
|
|||
|
Well,
I have my own server, but that is windows 2000. nice belgium site btw greets |
|
#4
|
||||
|
||||
|
Thx, but it's not belgian... It's dutch. But thx anyway, I think you just recognized some words or something.
Ontopic: With Win2k it must be less difficult than with Linux. Still, I think it's very hard. I've used FreeTDS, but I don't know if it can be used on Windows too. Take a search for it, there's lots of info when you search for FreeTDS. I stand with my earlier post, when you can do it with mySQL, use MySQL. |
|
#5
|
|||
|
|||
|
if your just looking for code to connect PHP to sql server...
$server = "ipaddress ortnumber"; //this is ipaddress-colon-portnumber (i don't know where the picture is coming from)$user = "username”; $passwd = “password”; $db_name = "dbanme”; $table_name = "tablename”; $conn = mssql_connect($server, $user, $passwd) or die("Couldn't connect to SQL Server on $server"); mssql_select_db($db_name, $conn); $query = "SELECT * FROM $table_name "; $result = mssql_query( $query ); |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > PHP - MS SQL connection |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|