diff options
Diffstat (limited to 'cms/content.php')
-rw-r--r-- | cms/content.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/cms/content.php b/cms/content.php new file mode 100644 index 0000000..02ea225 --- /dev/null +++ b/cms/content.php @@ -0,0 +1,40 @@ +<?php
+ error_reporting(E_ALL | E_STRICT);
+ ini_set("display_errors", 1);
+
+ /* create connection */
+ $connection = mysql_connect("localhost", "sandbox", "brotato333");
+ if (!$connection)
+ die("Could not connect to the database: " . mysql_error());
+
+ /* once you get the handle, select a database to use */
+ $db_select = mysql_select_db("sandbox", $connection);
+ if (!$db_select)
+ die("Failed to select a database: " . mysql_error());
+?>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Hacker's Corner</title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+</head>
+<body>
+<h2>Hello, world!</h2>
+<p>
+<?php
+ /* the return type is of resource, collection of rows essentially */
+ $query = mysql_query("select * from subjects", $connection);
+ if (!$query)
+ die("Could not query: " . mysql_error());
+
+ while ($row = mysql_fetch_array($query)) /* for each row */
+ echo $row[1] . " " . $row[2] . "<br />\n"; /* note, [0] would be the id field */
+
+ mysql_close($connection);
+?>
+</p>
+</body>
+</html>
+
|