Link to home
Start Free TrialLog in
Avatar of RAGAB2000
RAGAB2000

asked on

How to connect to INFORMIX DataBase Or MS SQL DataBase?

Dear's
I an installing PHP (ZEND Studio4) and use it as editor for PHP, On Window XP.
I have a Informix data base installed on NT4 Server.
I want to connect to this database with PHP and try to write code to do this but I have error message.
Here the code
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<?
$db_user =         "user";       // username for db
$db_password =     "password";        // password for db
$db =              "database@server";    // db to use

$db_query =    "select id, product from catalog";

$conn_id = ifx_connect("$db", "$db_user", "$db_password");
$result = ifx_query($db_query, $conn_id);

    if ($result) {
    echo "These were in the catalog table:<ul>";
    while ($r = ifx_fetch_row($result)) {

    // reformat output

    $id = $r["id"];
    $product = $r["product"];

    echo "<li>$id, $product";

    }
    echo "</ul>";

        } else {
        echo "No data.";
        ifx_errormsg();
        }
ifx_free_result($result);
?>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
when run it i got the error message
---------------------------------------------------------------------------------------------------------
Debug Error: C:\Inetpub\wwwroot\PHP\ConnTest1.php line 8 - Call to undefined function ifx_connect()
---------------------------------------------------------------------------------------------------------
what error i did?
how can I connect in right code?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Klodorff
Klodorff

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rahulbhanot
rahulbhanot

I think it 'll help you to connect with the Database "MySql" ........  Please try it and also replace the "abc " with your database name

<?
$hostname="localhost";
$dbuser="root";
$dbpassword="";
$dbname="abc";

$connection = @mysql_connect("$hostname","$dbuser","$dbpassword") or Die("<b>Could not connect to the Database MySQL </b> ");
@mysql_select_db("$dbname",$connection) or Die("<b> Could not Select the Database abc</b> ");
?>
sorry the last solution for if the  Database is "My Sql "   but  with minor change now this is the solution for you  means  when the database  is  "MS SQL".

I think it 'll help you to connect with the Database "MS SQL" ........  Please try it and also replace the "abc " with your database name

<?
$hostname="localhost";
$dbuser="root";
$dbpassword="";
$dbname="abc";

$connection = @mssql_connect("$hostname","$dbuser","$dbpassword") or Die("<b>Could not connect to the Database MySQL </b> ");
@mssql_select_db("$dbname",$connection) or Die("<b> Could not Select the Database abc</b> ");
?>
No comment has been added to this question in more than 21 days,so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
[Points Split {Klodorff},{gruntar} and {rahulbhanot}]

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Kshitij Ahuja
EE Cleanup Volunteer