Hello world !
This tutorial will show you how to connect on your Pangya_S4_TH DB with PHP
Step
1 - Configure Server SQL
2 - Configure PHP
3 - Connection and SQL query test
What you need :
1) Microsoft Server SQL
2) Pangya_S4_TH installed
1 - Configure Server SQL
Execute "SQL Server Configuration Manager" (http://puu.sh/EKML)
Go to "SQL Server Network Configuration" then on "Protocols for MSSQLSERVER"
Enable Named Pipes and TCP/IP by right click -> Enable (http://puu.sh/EKRX)
Right click on TCP/IP => Properties
Protocol Tab => Listen All => Yes (http://puu.sh/EKT6)
IP Addresses Tab => IPAll => TCP Port => 1433 (http://puu.sh/EKTm)
Make sure Named Pipes and TCP/IP are Enabled in "SQL Native Client 10.0 Configuration" => "Client Protocols"
NB : If you have a 64 bits windows, you will have 2 "SQL Native Client 10.0 Configuration", one for 32 bits, and one for 64 bits
Go to "SQL Server Services"
Right click on "SQL Server (MSSQLSERVER)" => Restart (http://puu.sh/EKUL)
SQL Configuration finished !
2 - Configure PHP
Install php_pdo_odbc extension for PHP
if you have WAMP/EasyPHP, you just have to delete the ";" in front of the line "extension=php_pdo_odbc.dll" in php.ini
Restart apache
PHP Configuration finished !
3 - Connection and SQL query test
Now it's time to test !
I did this SQL query to test : SELECT * FROM [Pangya_S4_TH].[dbo].[Pangya_Item_WareHouse] and it work perfectlyPHP Code:<?php
$server = '127.0.0.1';
$database = 'Pangya_S4_TH';
$user = 'sa';
$passwd = '*****'; //Replace ***** by your passwd
$connect = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $passwd);
$sql = '...'; //Replace ... by the SQL query
$result = odbc_exec($connect, $sql;
while($array = odbc_fetch_array($result)) {
foreach($array as $key => $value) {
echo $key . " : " . $value . "<br/>";
}
echo '<br/><br/>';
}
?>
I hope it will help some of you to make a website to manage your Pangya Server ;)



Reply With Quote![[Tutorial] Connect to your DB with PHP](http://ragezone.com/hyper728.png)

