944,172 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 6173
  • PHP RSS
Apr 17th, 2006
0

php adodb library connect remote mysql

Expand Post »
Hi,

I have to connect sometimes to MSSQL and sometimes to MySql depending on the customer. I am experimenting with the php adodb library that claims to make database connection possible to either vendor using the same syntax.

First the background at home I have:

Rig1:
windows XP professional
PHP 5.0.4, IIS 5.1, MSSQL Server 2000 developer edition

Rig2:
Windows XP home
PHP 5.1.1, Apache 2.2.0, MySql 5.0.18-nt

So far if I connect and execute a query on Rig1 using two php files like this it works.

cls_gen_db.conf.php
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $_ADO_INC_PATH = 'C:/Inetpub/phpado';
  3.  
  4. $dbdriver = 'mssql';
  5. $server = 'localhost';
  6. $user = 'myusername';
  7. $password = 'mypassword';
  8. $database = 'mydatabase';
  9.  
  10. include($_ADO_INC_PATH.'/adodb/adodb.inc.php');
  11. ?>

class_generator.php
PHP Syntax (Toggle Plain Text)
  1. <html>
  2. <body>
  3. <?php
  4.  
  5. include('cls_gen_db.conf.php');
  6.  
  7. $Thedb = ADONewConnection($dbdriver);
  8. $Thedb->debug = true;
  9. $Thedb->Connect($server, $user, $password, $database);
  10.  
  11. $Thedata = $Thedb->Execute('exec sp_tables');
  12. if ($Thedata == false) die("failed");
  13. print '<table>';
  14. while (!$Thedata->EOF) {
  15. print '<tr>';
  16. for ($i=0, $max=$Thedata->FieldCount(); $i < $max; $i++){
  17. print '<td>';
  18. print $Thedata->fields[$i];
  19. print '</td>';
  20. }
  21. print '</tr>';
  22. $Thedata->MoveNext();
  23. }
  24. print '<table>';
  25. ?>
  26. </body>
  27. </html>

In theory to run a similar query on the MySql on Rig2 (it has same database name and user name setup) all I have to change is these two lines:
PHP Syntax (Toggle Plain Text)
  1. $dbdriver = 'mysql';
  2. $server = 'Rig2';

And this line in the other file:
PHP Syntax (Toggle Plain Text)
  1. $Thedata = $Thedb->Execute('show tables');

But I get a blank page, no PHP errors ? if I copy the PHP files over to Rig2 and browse them via Apache web server locally it all works, but If PHP on Rig1 tries to query mysql on Rig2, I get nothing, not even an error. If I view source i see <html><body> but nothing else.

I am lost to know what the problem is (The SP2 firewall on Rig2 is configured to allow incoming TCP/IP on port 3306 from any other host on my home LAN)

What gives?
Similar Threads
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Apr 22nd, 2006
0

Re: php adodb library connect remote mysql

Try using the IP of Rig2 as the $server varible.
Reputation Points: 10
Solved Threads: 1
Light Poster
BlazingWolf is offline Offline
32 posts
since Feb 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Do You Know Sessions! HELP PLEASE!
Next Thread in PHP Forum Timeline: Deselect the Radio Button





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC