Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement