Q:

PHP ForEach Error

Here is my code:
<?php
  $query1 = 'SELECT * From Drink';
  $GetName= mysql_query($query1);?>

<?php foreach ($GetName as $GetNames) : ?>
        <?php echo $GetNames['Name']; ?>
        <?php endforeach; ?>

The error I'm getting is this: 
Warning: Invalid argument supplied for foreach() in (removed for privacy) on line 16

I've looked at other questions similar to this one, and they don't quite answer the question. I'm not interested (currently) in finding a different way to go about doing this. I already have an alternate way, but I was taught this way and I'd like to know why it is failing.
It isn't a problem with the database or the query, because this:
<?php
  if ($GetName) {
            while($row = mysql_fetch_array($GetName)) {
                $name = $row["Name"];
                echo "$name<br>";
            }
        }

Works just fine.
Can anyone help me?

A:

So, I got it working. The problem was the way I connected to the database. Once I switch to PDO, as IOIO MAD implied, it worked just fine. Also Kudos to Itay Moav -Malimovka, because his suggestion did get rid of the error. Thanks for all of your help everyone, I'm glad I got this resolved.

