PielaatITC Posted November 15, 2011 Share Posted November 15, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/251191-odbc-connection-problems/ Share on other sites More sharing options...
phporcaffeine Posted November 15, 2011 Share Posted November 15, 2011 Do you actually see the 'Connection Failed' text that your code is designed to echo out? I assume you realize that you need to pass a username and password to the odbc_connect and have them removed for the forum. Quote Link to comment https://forums.phpfreaks.com/topic/251191-odbc-connection-problems/#findComment-1288368 Share on other sites More sharing options...
PielaatITC Posted November 16, 2011 Author Share Posted November 16, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/251191-odbc-connection-problems/#findComment-1288624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.