Jump to content

odbc connection problems


PielaatITC

Recommended Posts

Hello, I'm new at PHP programming. I'm creating a simple application. I created a form where users can fill in some data. One of the fields is a username. This is a drop down list. This list is build up with data from SQL Server 2005 R2. I created the code in PHPDesigner7. The ODBC connection is working fine in PHPDesigner7. When I try to run it on the localhost I get no connection

The code I used :

 

            <?php

                $conn=odbc_connect('MyDataBase','','');

                echo "connectie ".$conn;

                if (!$conn)

                    {exit("Connection Failed: ". $conn);}

       

                $sql="SELECT Id, [Name] FROM Names";

                $rs=odbc_exec($conn,$sql);         

   

                $options="";

 

                echo "<br />";

                echo "User : ";               

                echo "<select name='QCT_name'>";

               

                while ($row=odbc_fetch_array($rs))

                {

                    $id= $row["Id"];

                    $Controleur = $row["Name"];

                    echo "<option value='".$row['Id']."'>".$row['Name']."</option>";

                }         

                echo "</select>";

                echo "<br />";

             

            ?>

 

Has anybody any clue what I'm doing wrong?

 

Link to comment
https://forums.phpfreaks.com/topic/251191-odbc-connection-problems/
Share on other sites

Yes, The text is displayed. The $conn is empty. The text which is echoed is : "Connection Failed: ". The strange thing is that it works when I run it within PHPDesigner7 (the echo of the connection number  = #1). In PHPDesigner7 you have the possibility to just run it within the application and also to run it within IE  (it's using then C:\Inetpub\wwwroot\~QC_Index.php.htm) and both works.

Only when I run it directly in IE by using "http://localhost/QC_index.php" it doesn't work. Can this be a security issue from IE and if yes do you know how to solve this?

The SQL server database is on another server, but the user I'm using is Administrator on both machines (VM).

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.