Last active
August 29, 2015 14:19
-
-
Save vdespa/ee06bafb128149e4184f to your computer and use it in GitHub Desktop.
Mysql connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$username = "your_name"; | |
$password = "your_password"; | |
$hostname = "localhost"; | |
//connection to the database | |
$dbhandle = mysql_connect($hostname, $username, $password) | |
or die("Unable to connect to MySQL. \n" . mysql_errno($link) . ": " . mysql_error($link). "\n"); | |
echo "Connected to MySQL<br>"; | |
//select a database to work with | |
$selected = mysql_select_db("docker",$dbhandle) | |
or die("Could not select docker." . mysql_errno($link) . ": " . mysql_error($link). "\n"); | |
//execute the SQL query and return records | |
$result = mysql_query("SELECT * FROM docker_data"); | |
//fetch tha data from the database | |
while ($row = mysql_fetch_array($result)) { | |
echo "ID:".$row{'id'}." Description:".$row{'description'}."<br>"; | |
} | |
//close the connection | |
mysql_close($dbhandle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment