Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>PasdfaHP Test</title>
- </head>
- <body>
- <?php
- $link = mysql_connect('localhost:/tmp/mysql.sock', 'root', 'secret');
- if (!$link) {
- die('Could not connect: ' . mysql_error());
- }
- echo 'Connected successfully';
- // make users the current db
- $db_selected = mysql_select_db('testdb', $link);
- if (!$db_selected) {
- die ('\nCan\'t use users : ' . mysql_error());
- }
- $id = '0001';
- $query = sprintf("SELECT name FROM users WHERE id='%s'",mysql_real_escape_string($id));
- $result = mysql_query($query);
- while ($row = mysql_fetch_assoc($result)) {
- echo $row['name'];
- }
- mysql_free_result($result);
- mysql_close($link);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement