ODBC Connecting to SQL Database in PHP Error -


i have php file proper information, , cannot figure out why cannot make odbc connection sql database?

i have 2 files , trying create simple webpage connected database.

first file (odbc_vertices.php):

   <?php     //creates odbc connection , stores in $odbc variable    $odbc = odbc_connect ('vertices', 'correctusername','correctpassword') or die ( "could not connect odbc database!" );     ?> 

second file (phptest.php):

   <html>     <head>    <title></title>    </head>     <body>     <?php      include 'odbc_vertices.php';     ?>     <select name='vndr'>   <option selected>   <?php      $query =odbc_exec($odbc_vertices,"select * tblorder receive=no order  tapetype") or die (odbc_errormsg());             while ($row=odbc_fetch_array($query))                    {                       echo "<option value='".$row['vendorname']."'>".strtoupper($row ['vendorname'])."</option>";                     }    ?>       </select>       <input type=hidden name='nam' size='2'>         <?php     odbc_close($odbc_vertices);    ?>     </body>     </html> 

however i'm receiving error when go test page:

warning: odbc_connect() [function.odbc-connect]: sql error: [microsoft][odbc sql server driver][sql server]login failed user 'nt authority\anonymous logon'., sql state 28000 in sqlconnect in odbc_vertices.php on line 4 not connect odbc database!

i'm trying figure out should changed in odbc_vertices.php file connection successful. appreciated

my thought odbc dsn "vertices" setup incorrectly on machine itself.

my suggestion try code similar to:

$conn = odbc_connect("driver={sql server native client 10.0};server=yourserverdatabase=database", 'correctusername','correctpassword'); $query = odbc_exec($conn,"select * tblorder ...") or die (odbc_errormsg()); 

other connection strings, if above fails, can found @ http://www.connectionstrings.com/sql-server/

my other thought user permissions inside database not correctly setup allow correctusername access database


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -