Re: freetds and php configiration

Tareq <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
 

Iam using this scripts  to connect to sql 2000 db , I was wondering if you
can help , mssql extension don’t seem to work at all despite the fact that
its installed with php , what is your php configuration ? Did you add and
special configuration to your php installation ?

 

<?php

error_reporting(E_ALL);

class Config{

      public function __construct(){

 

      }     

 

      public function connect_31_ref()

      {

            $conn = @mssql_connect("116.285.216.31:5831", "Omari2",
"LYUA0QYL7WKvM");

//          $conn = @mssql_connect("116.285.216.31:5831", "test_link",
"test_link");

            if (!$conn)

            {

                  die("Error connecting to MSSQL=>: " .
mssql_get_last_message() . " error here");

            }

 

            if (!mssql_select_db("ref_system", $conn))

            die("Error selecting from database: " .
mssql_get_last_message());

      return $conn;

}

 

}

echo __LINE__ . "<br>";

$conn=new Config();

echo __LINE__ . "<br>";

$start=$conn->connect_31_ref();

echo __LINE__ . "<br>";

$stmt=mssql_init("myprocedure", $conn);

echo __LINE__ . "<br>";

$id =5;

$name="alaa Alomari";

mssql_bind($stmt, "@id",    $id,    SQLINT4,    FALSE);

echo __LINE__ . "<br>";

mssql_bind($stmt, "@namex",  $name,  SQLVARCHAR, FALSE);   

echo __LINE__ . "<br>";

$result = mssql_execute($stmt);

echo __LINE__ . "<br>";

if (!$result)

      echo mssql_get_last_message();

echo __LINE__ . "<br>";

$output=mssql_fetch_assoc($result);

echo __LINE__ . "<br>";

print_r($output);

 

 

?>

 

 

 

 

Tarek Atallah

Senior Database Administrator

Tahadi Games - www.tahadi.com

Mobile +962 776555508

E-mail W : [email protected]

E-mail P  : [email protected]

 

 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Per Stenebo
Sent: Monday, October 26, 2009 2:01 PM
To: FreeTDS Development Group
Subject: Re: [freetds] freetds and php configiration

 

This is a test script I've been using to connect to a MS SQLserver 2005 thru

PHP and FreeTDS:

It simply connects and list user tables in the DB.

 

<html>

<body>

 

<?php

$db = "mydatabase";

 

  $con = odbc_connect("databaseserver", "domain\\username", "password");

  if (!$con)

    {

        print("There is a problem with SQL Server connection.\n");

      }

  else

    {

        print("The SQL Server connection object is ready.\n");

 

// List user tables in database

        echo "<h4>Tables in database $db</h4>";

        $sql = "select name from $db..sysobjects where xtype = 'U'";

        $result = odbc_exec($con, $sql) or die(odbc_errormsg($con));

        while (odbc_fetch_row($result))

            {

                print("<p>" . odbc_result($result,1) . "</p>\n");

            }

 

        odbc_free_result($result);

        odbc_close($con);

    }

?>

 

 

</body>

</html>

 

I think the keywords to use in searching for help are "php ODBC".

Hope it helps.

/Per Stenebo

 

 

2009/10/26 Tareq <[email protected]>

 

> Hi all ,

> 

> I have installed  freetds and php, now how I can configure php to use tds?

> 

> Any help please?

> 

> 

> 

> 

> Tarek Atallah

> Senior Database Administrator

> Tahadi Games - www.tahadi.com

> Mobile +962 776555508

> E-mail W : [email protected]

> E-mail P  : [email protected]

> 

> 

> -----Original Message-----

> From: [email protected]

> [mailto:[email protected]] On Behalf Of Frediano Ziglio

> Sent: Sunday, October 25, 2009 10:41 AM

> To: [email protected]; FreeTDS Development Group

> Subject: Re: [freetds] Is MS SQL Server closes cursor on every

> commit/rollback?

> 

> This is a server setting. Do you really need to use this option?

> 

> freddy77

> 

> Il giorno 25/ott/2009, alle ore 09.08, [email protected] ha scritto:

> 

> > Hi, ALL,

> > I am trying to develop a program that will

> > use an ODBC connection to different DB.

> > It will be based on some other C++ library.

> >

> > What I found is that the comment to the ODBC interface

> > for this library says following:

> >

> > // By default, MS Sql Server closes cursors on commit and rollback.

> > The following

> > // call to SQLSetConnectOption() is needed to force SQL Server to

> > preserve cursors

> > // after a transaction.  This is a driver specific option and is not

> > part of the

> > // ODBC standard.  Note: this behavior is specific to the ODBC

> > interface to SQL Server.

> > // The database settings don't have any effect one way or the other.

> > const long SQL_PRESERVE_CURSORS = 1204L;

> > const long SQL_PC_ON = 1L;

> > /* retcode = */ SQLSetConnectOption(hdbc, SQL_PRESERVE_CURSORS,

> > SQL_PC_ON);

> >

> > Is this true for all version of MS SQL Server or just for an old ones?

> > Is it the same for Sybase as well?

> >

> > What I will gain/lose when this will be disabled?

> >

> > Thank you.

> >

> > _______________________________________________

> > FreeTDS mailing list

> > [email protected]

> > http://lists.ibiblio.org/mailman/listinfo/freetds

> _______________________________________________

> FreeTDS mailing list

> [email protected]

> http://lists.ibiblio.org/mailman/listinfo/freetds

> 

> _______________________________________________

> FreeTDS mailing list

> [email protected]

> http://lists.ibiblio.org/mailman/listinfo/freetds

> 

 

 

 

-- 

MVH Per Stenebo

Ballingslöv

0708-78 18 24

_______________________________________________

FreeTDS mailing list

[email protected]

http://lists.ibiblio.org/mailman/listinfo/freetds

 

 

 

 

Tarek Atallah

Senior Database Administrator

Tahadi Games - www.tahadi.com

Mobile +962 776555508

E-mail W : [email protected]

E-mail P  : [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.