Dear visitor, despite the COVID-19 outbreak, our team continues operating at full speed.

Also, here is the form where you can apply for a special discount and we will contact you with possible options. Stay safe and continue achieving your business goals.

Fill the form
Get Free Trial
Get Free Trial

How to connect to a sql database with php

Patchy TN asked on January 18, 2017

Hi,I’m new to all of this and don’t know much about sql.
I read the guide but still confuse about this
Step 2: Setup Data Compressor on the server
First of all, you need to add the following dependency to your project, flexmonster-compressor.php is located in the Download Package:


Below is the connection and query sample for MySQL database:

mysql_connect($server, $username, $password);
$result = mysql_query("SELECT * FROM customer");

The following line of code will start streaming compressed $result:

header('Content-Type: text/plain');

What I understand is just put flexmonster-compressor.php to the server,right?
and then where should I put the sql query code? in flexmonster-compressor.php or in another file?

2 answers

Ian Sadovy Flexmonster January 18, 2017

Hello Patchy,
Thank you for the question.
Yes, you should put flexmonster-compressor.php on the server.
Also, you should create a separate PHP file with all code from Step 2.
SQL query is defined in the following line of code:

$result = mysql_query("SELECT * FROM customer");

You can find fully working PHP sample in the downloaded package for SQL (/server/php/).
Does it work for you?

Patchy TN January 19, 2017

it works,thank you!

Please login or Register to Submit Answer