Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- const HOST = 'localhost';
- const USER = 'abhinav';
- const PASS = '1234';
- const DB = 'abh';
- try
- {
- $conn = new PDO("mysql:host = ".HOST.";dbname = ".DB."", USER, PASS);
- if($conn)
- {
- echo "success";
- }
- else
- {
- echo "error";
- }
- $query = "select uid from users";
- foreach($conn->query($query) as $row)
- {
- echo $row['uid'];
- }
- $conn = null;
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- ?>
- //it is giving me following message ....successPHP Warning: Invalid argument supplied for foreach() in /home/abhinav/pdo_test.php on line 20....please help me how to fix it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement