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
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).

 

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.