From 0807e2ee9d6748ce6bb0661ef11f06a322edda89 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 1 Jan 2011 08:50:02 -0500 Subject: [PATCH] yet more mysql stuff --- docroot/html/mysql.php | 127 +++++++++++++++++++++++++++++++++++------ docroot/php.ini.in | 6 +- docroot/setup.sql | 8 +-- 3 files changed, 116 insertions(+), 25 deletions(-) diff --git a/docroot/html/mysql.php b/docroot/html/mysql.php index 64b8611..d61c3b9 100644 --- a/docroot/html/mysql.php +++ b/docroot/html/mysql.php @@ -1,19 +1,32 @@ + clear + - -

Creating tables...

query("DROP TABLE IF EXISTS customers");
+        $create_result = $MYSQLCONN->query("
+            CREATE TABLE customers (
+                customer_id MEDIUMINT NOT NULL AUTO_INCREMENT,
+                name VARCHAR(255) NOT NULL,
+                email VARCHAR(255) NOT NULL,
+                PRIMARY KEY(customer_id)
+            ) ENGINE=InnoDB
+        ");
 
-    ?>
+ if (!$create_result) { + printf("Failed to create tables: %s\n", $MYSQLCONN->error); + } else { + printf("%d Row inserted.\n", $MYSQLCONN->affected_rows); + print_r($MYSQLCONN->query("DESCRIBE customers")); + print_r($MYSQLCONN->query("SELECT * FROM customers")); + } -
+
clearprepare( + "INSERT INTO customers (customer_id, name, email) VALUES (NULL, ?, ?)" + ); + $add_customer->bind_param('ss', $_POST["name"], $_POST["email"]); + $result = $add_customer->execute(); + + if (!$result) { + ?>

Failed to create customer!: error ?>

affected_rows; ?> Row inserted.

-
- - + +
+ Database Admin + + + + + + + + + + + + + +
+
+ +
+
Add Customer + + + + + + + + + + +
+ +
query("SELECT * FROM customers");
+            while ($row = $results->fetch_array(MYSQLI_ASSOC)) {
+                print_r($row);
+            }
+        ?>
+ + +close(); + +?> diff --git a/docroot/php.ini.in b/docroot/php.ini.in index 1cb68dc..2c8e921 100644 --- a/docroot/php.ini.in +++ b/docroot/php.ini.in @@ -528,7 +528,7 @@ error_reporting = E_ALL & ~E_DEPRECATED ; Development Value: On ; Production Value: Off ; http://php.net/display-errors -display_errors = Off +display_errors = On ; The display of errors which occur during PHP's startup sequence are handled ; separately from display_errors. PHP's default behavior is to suppress those @@ -539,7 +539,7 @@ display_errors = Off ; Development Value: On ; Production Value: Off ; http://php.net/display-startup-errors -display_startup_errors = Off +display_startup_errors = On ; Besides displaying errors, PHP can also log errors to locations such as a ; server-specific log, STDERR, or a location specified by the error_log @@ -601,7 +601,7 @@ track_errors = Off ; Development Value: On ; Production value: Off ; http://php.net/html-errors -html_errors = Off +html_errors = On ; If html_errors is set On PHP produces clickable error messages that direct ; to a page describing the error or function causing the error in detail. diff --git a/docroot/setup.sql b/docroot/setup.sql index 7c15acb..937eece 100644 --- a/docroot/setup.sql +++ b/docroot/setup.sql @@ -1,6 +1,6 @@ -CREATE TABLE IF NOT EXISTS customers ( +CREATE TABLE customers ( customer_id INTEGER, - name VARCHAR(255), - email VARCHAR(255), + name VARCHAR(255) NOT NULL, + email VARCHAR(255) NOT NULL, PRIMARY KEY(customer_id) -); +) AUTO_INCREMENT = 1, ENGINE = InnoDB