note 50063 added to function.odbc-connect
| From: | aamaral at 0kbps dot net | Date: | Wed, 16 Feb 2005 20:29:32 +0000 |
| Subject: | note 50063 added to function.odbc-connect | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85139@lists.php.net to get a copy of this message | ||
To connect to Sybase SQL Server Anywhere 8.0 on Windows use the following:
<?php
//================================================================
// Configure connection parameters
$db_host = "server.mynetwork";
$db_server_name = "Dev_Server";
$db_name = "Dev_Data";
$db_file = 'c:\dbstorage\dev.db';
$db_conn_name = "php_script";
$db_user = "dbuser";
$db_pass = "dbpass";
//================================================================
$connect_string = "Driver={Adaptive Server Anywhere 8.0};".
"CommLinks=tcpip(Host=$db_host);".
"ServerName=$db_server_name;".
"DatabaseName=$db_name;".
"DatabaseFile=$db_file;".
"ConnectionName=$db_conn_name;".
"uid=$db_user;pwd=$db_pass";
// Connect to DB
$conn = odbc_connect($connect_string,'','');
// Query
$qry = "SELECT * FROM my_table";
// Get Result
$result = odbc_exec($conn,$qry);
// Get Data From Result
while ($data[] = odbc_fetch_array($result));
// Free Result
odbc_free_result($result);
// Close Connection
odbc_close($conn);
// Show data
print_r($data);
//================================================================
?>
----
Manual Page -- http://www.php.net/manual/en/function.odbc-connect.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50063
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50063&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50063&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50063&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50063&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50063&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50063&report=yes
Search -- http://master.php.net/manage/user-notes.php