Last active
August 28, 2016 18:07
-
-
Save ederrafo/fd466d1e3cec86fc739ef473f3776ccf to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$host = "10.0.2.2"; | |
$user = "root"; | |
$pwd = "root"; | |
if (!$link = mysql_connect( $host, $user, $pwd )) { | |
echo 'Could not connect to mysql'; | |
exit; | |
} | |
if (!mysql_select_db('my_database', $link)) { | |
echo 'Could not select database'; | |
exit; | |
} | |
$sql = 'SELECT * FROM products'; | |
$result = mysql_query($sql, $link); | |
if (!$result) { | |
echo "DB Error, could not query the database\n"; | |
echo 'MySQL Error: ' . mysql_error(); | |
exit; | |
} | |
while ($row = mysql_fetch_assoc($result)) { | |
echo $row['id']." | ".$row['name']; | |
} | |
mysql_free_result($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment