• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 571
  • Last Modified:

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
0
RAGAB2000
Asked:
RAGAB2000
2 Solutions
 
KlodorffCommented:
checkout the first contributed user note at: www.php.net/ifx_connect
he seems to have meet the similar probleme as you.

/klod
0
 
gruntarCommented:
you have to enable ifx module forst. Open your php.ini file find line

;extension=php_ifx.dll

and remove semicolon in front of the line. then restart server.

cheers
0
 
rahulbhanotCommented:
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> ");
?>
0
 
rahulbhanotCommented:
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> ");
?>
0
 
Kshitij AhujaCommented:
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now