Two questions: Extract Images & Searching a server

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ithilien
Posts: 33
Joined: Tue 27 Feb 2007 21:58

Two questions: Extract Images & Searching a server

Post by Ithilien » Thu 09 Aug 2007 07:52

Hello, i'm building an application using MySQL DAC Standard edition and i have "two problems":

The first, i'm trying to looking for a MySQL server in a intranet using an user that is created for this, for example: The DBA creates an user: 'db', password: 'db' and a thread or a process explore all the range of the private net class C ( 192.168.x.x ). If any connection has a success ( MyConnection->Connected == true ), The IP was found in the intranet. So i do MyConnection->Connect() with this parameters, but i put the timeout low to not take several seconds trying connect. When i proof this method, my application was so slowing so i don't know another tactic / method or another parameter for MyConnection to bring it more fast. Any solution?

The second problem is using PHP. I store Images as BMP images Using parameteres in a SQL statement ( INSERT INTO ..... VALUES (...., :image, .... );
MyConsulta->ParamByName("image")->AsBlobRef->LoadFromFile("C:\temp.bmp");
That's right.

When i try to recover this image using PHP, appear strange characters:
#+f�%2j�->o�-Aq�g�f�e�c�b�^�\�Z�W�Y�Z�`�d�c�a�_�\�
In my web browser, so i don't know where is the problem.
The PHP code is the following:

Code: Select all

$result = mysql_query("SELECT photo FROM person WHERE IDC = 111111");
$result_array = mysql_fetch_array($result);
header("Content-Type: image/bmp");
echo $result_array[0];
Thanks a lot!

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 09 Aug 2007 08:28

> The first, i'm trying to looking for a MySQL server in a intranet

Please try to set Connection.Server in IP format. Also try to set skip-name-resolve server variable. You can read more about it in MySQL Reference Manual

> The second problem is using PHP

Please check BMP uploading using MyDacDemo (Pictures Frame). Do you see any problem?

Ithilien
Posts: 33
Joined: Tue 27 Feb 2007 21:58

Post by Ithilien » Thu 09 Aug 2007 09:52

Hi Ikar, Thank you for your fast reply.

For the first question about IP format, i have a timer thats increment de IP address between the interval 0-255 for the third and fourth byte of the IP ( 192.168.x.x ) so the problem is in the connection that takes a lot of time i see. I'll read the Manual looking for these variable.

The second. My program works perfectly doing select and showing pictures downloaded from the MySQL database so the upload is done correctly. However, the problem maybe in the BMP format? I wait your response. Thanks

Ithilien
Posts: 33
Joined: Tue 27 Feb 2007 21:58

Post by Ithilien » Thu 09 Aug 2007 10:22

About the skip-name-resolve, i restart my MySQL server using this parameter:

Code: Select all

>mysqld --skip-name-resolve
and it works at the same speed as the classic MySQL start. I set the connection TimeOut to 2 seconds to make it faster, but i suppose that the searching will still be slowly...

If you have another idea, please, post it. Thanks!

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 09 Aug 2007 12:09

> The first, i'm trying to looking for a MySQL server in a intranet

Try to count connection time from other MySQL clients. For example, from command-line mysql.exe tool.

> About the skip-name-resolve
> and it works at the same speed

Try to execute SHOW VARIABLES statement to check actual skip-name-resolve value.

>I set the connection TimeOut to 2 seconds to make it faster

Setting small TimeOut value doesn't increase performance. It just sets time to raise an exception.


> The second problem is using PHP
> the problem maybe in the BMP format

Most possible the problem is in PHP code. Try to ask this question on PHP-specific forums.

Ithilien
Posts: 33
Joined: Tue 27 Feb 2007 21:58

Post by Ithilien » Fri 10 Aug 2007 18:29

Ok, i'm asking in PHP-specific forums, but i have the last question:

Is possible that the storage mode of MySQL Data Access Component would have incompatibilities between PHP to recover images? All fields appear in my web browser correctly, but the Image no.

Thanks.

Ithilien
Posts: 33
Joined: Tue 27 Feb 2007 21:58

Post by Ithilien » Sat 11 Aug 2007 00:18

problem solved. Thanks

Post Reply