How to connect to a sql database with php

Resolved
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:

require_once("flexmonster-compressor.php");

Below is the connection and query sample for MySQL database:

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

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

header('Content-Type: text/plain');
Compressor::compressMySql($result);

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

Public
Ian Sadovy 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?
 
Regards,
Ian

Public
Patchy TN January 19, 2017

it works,thank you!

Please login or Register to Submit Answer