01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
/*
* Anti-Pattern
*/
# Connect
mysql_connect('localhost', 'username', 'password') or die('Could not connect: ' . mysql_error());
# Choose a database
mysql_select_db('someDatabase') or die('Could not select database');
# Perform database query
$query = "SELECT * from someTable";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
# Filter through rows and echo desired information
while ($row = mysql_fetch_object($result)) {
echo $row->name;
}