[problem]
you want to run queries against a Sybase Database, using the PHP API.
[/problem]
[solution]
A PHP script using sybase API for PHP, connect as given user, with your password on specific host.
[/solution]
[example]
Useful for monitoring sybase dbs, although in this instance it does not actually hit any database tables.
<?php
$user = "your_user";
$passwd = "password";
$host = "your_host";
$sql="select getdate(), @@version ";
$conn=sybase_connect($host,$user,$pass); // connect to db
print("running query host: $hostnuser: $usern");
$result = sybase_query ( $sql ); // Run query and store in array
$i = 0;
while($row = sybase_fetch_array($result)) {
// Loop around the array and print field or column 1 and 2
$i++;
$item1 = $row[0];
$item2 = $row[1];
echo "$i $item1 $item2";
}
sybase_close();
?>
[/example]
[reference]
[tags]Sybase PHP example, PHP Coding School[/tags]
[/reference]
If you have found my website useful, please consider buying me a coffee below 😉