How to connect to a sql database with php
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); mysql_select_db($dbname); $result = mysql_query("SELECT * FROM customer");
The following line of code will start streaming compressed
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?
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 (
Does it work for you?
it works,thank you!