Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- const HOST = 'localhost';
- const USER = 'abh';
- const PASS = '123';
- const DB = 'abc';
- try
- {
- $conn = new PDO("mysql:host = ".HOST.";dbname = ".DB."", USER, PASS);
- if($conn)
- {
- echo "success";
- }
- else
- {
- echo "error";
- }
- $query = "select uid from users";
- $result = $conn->query($query);
- if(!$result)
- {
- print_r($conn->errorInfo());
- }
- else
- {
- foreach($result as $row)
- {
- echo $row['uid'];
- }
- }
- //$conn = null;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- 1,5
- ?>
- //i am getting following error
- /*successArray
- (
- [0] => 3D000
- [1] => 1046
- [2] => No database selected
- )
- */ //please tell me how to fix it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement