Quick post on how to connect to PSQL from PHP, run queries, and retrieve results. You can use the same syntax for inserts, updates and other statements.
linux-test# vim test.php
Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Wednesday, September 24, 2014
Tuesday, September 23, 2014
PHP - Reading a file into an array
Quick post on how to read a file into an array. As always there are more than one way to do this.
First create a test.txt file with some lines in it.
linux-test# echo 1st line >> test.txt
linux-test# echo 2nd line >> test.txt
linux-test# echo 3rd line >> test.txt
linux-test# echo 4th line >> test.txt
First create a test.txt file with some lines in it.
linux-test# echo 1st line >> test.txt
linux-test# echo 2nd line >> test.txt
linux-test# echo 3rd line >> test.txt
linux-test# echo 4th line >> test.txt
Wednesday, August 20, 2014
PHP - Connecting to MYSQL and running queries
TIDBIT blogtorial - Short and informational.
Many more articles to come so ....
Please subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.
MYSQL connection and handling queries
// Create connection
$con=mysqli_connect("localhost","username","password","dba");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Query String
$current_query = "select test from testtable";
//Get the results
$current_query_result = mysqli_query($con,$current_query);
//Loop through the results
while ($row = mysqli_fetch_array($current_query_result, MYSQL_NUM)) {
echo "Row value is $row[0]\n";
}
Many more articles to come so ....
Please subscribe/comment/+1 if you like my posts as it keeps me motivated to write more and spread the knowledge.
Subscribe to:
Posts (Atom)
