Archive for the ‘PHP’ Category

Disable open_basedir checking

Thursday, February 22nd, 2007

in httpd.conf

php_admin_value open_basedir none

Connecting to MSSQL from PHP in Linux

Saturday, February 10th, 2007

Installing FreeTDS

wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
./configure \
–prefix=/usr/local/freetds \
–enable-msdblib
make
make install

Configuring php

./configure \
–with-apxs2=/usr/local/apache/bin/apxs \
–with-openssl \
–enable-track-vars \
–with-mysql=/usr/local/mysql/ \
–with-mssql=/usr/local/freetds

Sample Code

$s = “server:1433”;
$u = “sa”;
$p = “password”;

$msconnect=mssql_connect ($s,$u,$p);
$msdb=mssql_select_db(“Northwind”,$msconnect);
$msquery = “select titleofcourtesy,firstname,lastname from employees”;
$msresults= mssql_query($msquery);
$msconnect=mssql_connect ($s,$u,$p);
$msdb=mssql_select_db(“Northwind”,$msconnect);
$msquery = “select titleofcourtesy,firstname,lastname from employees”;
$msresults= mssql_query($msquery);
while ($row = mssql_fetch_array($msresults)) {
echo $row[‘titleofcourtesy’] .” “. $row[‘firstname’] .” “. $row[‘lastname’] ;
}