Jump to content

Simple Sybase Connect


ellchr3
Go to solution Solved by ellchr3,

Recommended Posts

I get the following error with the code below:  

Parse error: syntax error, unexpected T_IF in C:\prov

 

Any help is appreciated.  Thanks!

 

<?php

$link = sybase_connect("10.x.x.x:x", "x", "x")

if ( ! $link ) { 

       echo "Connection failed \n "             

    } else { 

       echo "Connected successfully \n " ;

      sybase_close($link);

?>
Link to comment
Share on other sites

Okay, I found where I was missing a curly bracket too.  Updated code and error below.  It's not liking my connection parameters apparently.  

 

Below is the syntax for a sybase_connect.  Can you tell me if servername is the "Server Name" for Sybase, or the PC/server the database is on?  

 

 

sybase_connect ([ string $servername [, string $username [, string $password [, string $charset [, string $appname [, bool $new = false ]]]]]] )

 

Fatal error: Call to undefined function sybase_connect() in C.... on line 2

 

 

<?php
$link = sybase_connect("10.x.x.x:x", "x", "x");
if ( ! $link ) { 
       echo "Connection failed \n " ;           
    } else { 
       echo "Connected successfully \n " ;
    }
      sybase_close($link);
 
?>
 
Thanks for your help.
Link to comment
Share on other sites

  • Solution

I found a way that works using odbc_connect.  I couldn't get anything to work with the sybase_connect no matter what I tried.  I don't think it included enough information about the server/database that way.

 

<?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={Sql Anywhere 11};".
                    "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";
 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.