Useful PHP script – running queries against sybase database


you want to run queries against a Sybase Database, using the PHP API.



A PHP script using sybase API for PHP, connect as given user, with your password on specific host.



Useful for monitoring sybase dbs, although in this instance it does not actually hit any database tables.


$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
$item1 = $row[0];
$item2 = $row[1];
echo "$i $item1 $item2";



[tags]Sybase PHP example, PHP Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

Your email address will not be published. Required fields are marked *