odbc-connect error--urgent

Thread Solved

Join Date: Jan 2008
Posts: 26
Reputation: abdulraqeeb33 is an unknown quantity at this point 
Solved Threads: 0
abdulraqeeb33 abdulraqeeb33 is offline Offline
Light Poster

odbc-connect error--urgent

 
0
  #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 8:20 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1,614
Reputation: scru has a spectacular aura about scru has a spectacular aura about 
Solved Threads: 131
Featured Poster
scru's Avatar
scru scru is offline Offline
Posting Virtuoso

Re: odbc-connect error--urgent

 
0
  #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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 26
Reputation: abdulraqeeb33 is an unknown quantity at this point 
Solved Threads: 0
abdulraqeeb33 abdulraqeeb33 is offline Offline
Light Poster

Re: odbc-connect error--urgent

 
0
  #3
Apr 25th, 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 8:20 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 26
Reputation: abdulraqeeb33 is an unknown quantity at this point 
Solved Threads: 0
abdulraqeeb33 abdulraqeeb33 is offline Offline
Light Poster

Re: odbc-connect error--urgent

 
0
  #4
Apr 25th, 2008
thanks! its working now!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum


Views: 2678 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC