I am trying the following code:
<?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; $query = 'SELECT * FROM Auctions'; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { foreach($row as $field=>$value) { echo '$field: {$value} <br />'; } } mysql_close($link); ?>
And get this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Programme\EasyPHP 2.0b1\www\test.php on line 14
What am I missing?
You haven’t selected a database – use
mysql_select_db()That would be something like: