User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,199 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,127 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 425 | Replies: 3 | Solved
Reply
Join Date: Jan 2008
Posts: 26
Reputation: abdulraqeeb33 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
abdulraqeeb33 abdulraqeeb33 is offline Offline
Light Poster

odbc-connect error--urgent

  #1  
Apr 24th, 2008
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\xampp\htdocs\xampp\display.php on line 5
Connection Failed:

php is working fine, ran other simple php scripts...
but this is the error when i connect to a ms access db


  1. <html>
  2. <body>
  3.  
  4. <?php
  5. $conn=odbc_connect("DB",'','');
  6. if (!$conn)
  7. {exit("Connection Failed: " . $conn);}
  8. $sql="SELECT * FROM customers";
  9. $rs=odbc_exec($conn,$sql);
  10. if (!$rs)
  11. {exit("Error in SQL");}
  12. echo "<table><tr>";
  13. echo "<th>IP</th>";
  14. echo "<th>MAC</th></tr>";
  15. while (odbc_fetch_row($rs))
  16. {
  17. $name=odbc_result($rs,"ip");
  18. $macname=odbc_result($rs,"mac");
  19. echo "<tr><td>$name</td>";
  20. echo "<td>$macname</td></tr>";
  21. }
  22. odbc_close($conn);
  23. echo "</table>";
  24. ?>
  25.  
  26. </body>
  27. </html>

the dsn exists and i have selected a db which has the table clients_online and other fields such as ip and mac exist
Last edited by peter_budo : Apr 26th, 2008 at 7:20 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Location: St. Vincent and the Grenadines, Caribbean
Posts: 906
Reputation: scru is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 38
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Shark

Re: odbc-connect error--urgent

  #2  
Apr 24th, 2008
Are you sure it is a system dsn and not a user dsn? You must you the system tab in ODBC in the Administrative Tools to set up a system dsn.

HTH
Half and a half meck a whole, and I donned it a hundrid purcent
Reply With Quote  
Join Date: Jan 2008
Posts: 26
Reputation: abdulraqeeb33 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
abdulraqeeb33 abdulraqeeb33 is offline Offline
Light Poster

Re: odbc-connect error--urgent

  #3  
Apr 24th, 2008
oh thanks, i changed it to a system dsn now...
but i get this error msg




Warning: odbc_connect() [function.odbc-connect]: SQL error: Failed to fetch error message, SQL state HY000 in SQLConnect in C:\xampp\htdocs\xampp\display.php on line 5
Connection Failed:



program being this
  1. <html>
  2. <body>
  3.  
  4. <?php
  5. $conn=odbc_connect('data','','');
  6. if (!$conn)
  7. {exit("Connection Failed: " . $conn);}
  8. $sql="SELECT * FROM clients_online";
  9. $rs=odbc_exec($conn,$sql);
  10. if (!$rs)
  11. {exit("Error in SQL");}
  12. echo "<table><tr>";
  13. echo "<th>ip</th>";
  14. echo "<th>mac</th></tr>";
  15. while (odbc_fetch_row($rs))
  16. {
  17. $compname=odbc_result($rs,"ip");
  18. $conname=odbc_result($rs,"mac");
  19. echo "<tr><td>$compname</td>";
  20. echo "<td>$conname</td></tr>";
  21. }
  22. odbc_close($conn);
  23. echo "</table>";
  24. ?>
  25.  
  26. </body>
  27. </html>



Originally Posted by scru View Post
Are you sure it is a system dsn and not a user dsn? You must you the system tab in ODBC in the Administrative Tools to set up a system dsn.

HTH
Last edited by peter_budo : Apr 26th, 2008 at 7:20 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Join Date: Jan 2008
Posts: 26
Reputation: abdulraqeeb33 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
abdulraqeeb33 abdulraqeeb33 is offline Offline
Light Poster

Re: odbc-connect error--urgent

  #4  
Apr 25th, 2008
thanks! its working now!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC