Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   DB Tools (http://www.delphipages.com/forum/forumdisplay.php?f=7)
-   -   how connect mysql database in host (http://www.delphipages.com/forum/showthread.php?t=216412)

jr_ozv 06-24-2014 04:45 AM

how connect mysql database in host
 
hi
i want connect to mysql database in host
i install mydac component in delphi but closed 3306 port

Friends had suggested use php web service for connect database

How it should be done?

have example?

tnx:)

kolbasz 06-24-2014 08:41 AM

Did you install a mysql server to your computer or do you want to connect to a remote computer? Please be more specific!

jr_ozv 06-24-2014 09:05 AM

i want connect to remote compure

kolbasz 06-24-2014 09:26 AM

Quote:

i want connect to remote compure
Then make sure:
1. Remote access is enabled on the mysql server
2. A firewall/AV doesn't block your connection

Remote access is usually disabled for security reasons, so probably the best solution is to use a php webservice to communicate with the mysql service. You can send Get and Post commands from delphi with TIdHttp(just google it), and read the response.

jr_ozv 06-25-2014 04:27 AM

have you example ?

if have , plaease uploud.

tnx:)

kolbasz 06-25-2014 04:46 AM

Quote:

have you example ?
if have , plaease uploud.
tnx:)
Tested with Delphi XE2 and PHP 5.4.25. This will add two numbers, but you can do more complex operation, like read data from table, send receive images, etc...

1. Delphi

Drop a TidHTTP component and a TButton to your form. Doubleclick the button:
Code:

procedure TForm1.Button1Click(Sender: TObject);
var
  url: string;
  SS: TStringStream;
  SL: TStringList;
begin
  url := 'http://localhost/Delphi.php'; //<--change this to your URL
  SL := TStringList.Create;
  try
    SL.Add('a=' + IntToStr(4));
    SL.Add('b=' + IntToStr(5));
    SS := TStringStream.Create('');
    try
      IdHTTP1.Post(URL, SL, SS);
      ShowMessage(ss.DataString);
    finally
      SS.Free;
    end;
  finally
    SL.Free
  end;
end;

2. PHP(save this to delphi.php, and upload to your server)
Code:

<?php
  $a=$_POST['a'];
  $b=$_POST['b'];
  echo $a + $b;
?>


jr_ozv 06-25-2014 07:58 AM

thank you my dear friend
very gooood:)

Rantor777 11-08-2016 02:44 AM

HTTP Tunnel.
 
HTTP Tunneling is the Answer... Sorry. Late Reply.:(

Regards!


All times are GMT. The time now is 10:19 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.