Skip to content

Instantly share code, notes, and snippets.

@BlakeWilliams
Forked from Codercise/new.php
Created November 13, 2012 03:28

Revisions

  1. BlakeWilliams revised this gist Nov 13, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion new.php
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@
    $STH->bindParam(':level', $business["level"]);
    $STH->bindParam(':writeup', $business["writeup"]);
    $STH->bindParam(':image', $business["image"]);
    $STH->bindParam(':date', strtotime(date("Y-m-d")));
    $STH->bindParam(':date', strtotime(date("Y-m-d"), PDO::PARAM_STR)));
    $STH->execute();
    } catch(PDOException $e) {
    echo $e;
  2. @Codercise Codercise revised this gist Nov 13, 2012. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions new.php
    Original file line number Diff line number Diff line change
    @@ -14,13 +14,11 @@
    "date" => date('Y-m-d')
    );
    try {
    $date = date('Y-m-d');
    echo $business["date"];
    $DBH = new PDO('mysql:host=localhost;dbname=nickphay_noseyham', $username, $password);
    $data = array( 'name' => 'Cathy', 'addr' => 'herp derp', 'city' => 'cardiff' );
    $STH = $DBH->prepare("INSERT INTO business (name, country, email, phone, website, tagline, category,
    level, writeup, image, date-created) VALUES (:name, :country, :email, :phone, :website, :tagline,
    :category, :level, :writeup, :image, NOW())");
    :category, :level, :writeup, :image, :date)");
    $STH->bindParam(':name', $business["name"]);
    $STH->bindParam(':country', $business["country"]);
    $STH->bindParam(':email', $business["email"]);
    @@ -31,9 +29,10 @@
    $STH->bindParam(':level', $business["level"]);
    $STH->bindParam(':writeup', $business["writeup"]);
    $STH->bindParam(':image', $business["image"]);
    $STH->bindParam(':date', strtotime(date("Y-m-d")));
    $STH->execute();
    } catch(PDOException $e) {
    echo $e;
    echo "bad times :(";
    //file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
    }
    ?>
  3. @Codercise Codercise created this gist Nov 13, 2012.
    39 changes: 39 additions & 0 deletions new.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    <?php
    include('../../sqlconnection/config.php');
    $business = array(
    "name" => $_POST['name'],
    "country" => $_POST['country'],
    "email" => $_POST['email'],
    "phone" => $_POST['phone'],
    "website" => $_POST['website'],
    "tagline" => $_POST['tagline'],
    "category" => $_POST['category'],
    "level" => $_POST['level'],
    "image" => $_POST['image'],
    "writeup" => $_POST['writeup'],
    "date" => date('Y-m-d')
    );
    try {
    $date = date('Y-m-d');
    echo $business["date"];
    $DBH = new PDO('mysql:host=localhost;dbname=nickphay_noseyham', $username, $password);
    $data = array( 'name' => 'Cathy', 'addr' => 'herp derp', 'city' => 'cardiff' );
    $STH = $DBH->prepare("INSERT INTO business (name, country, email, phone, website, tagline, category,
    level, writeup, image, date-created) VALUES (:name, :country, :email, :phone, :website, :tagline,
    :category, :level, :writeup, :image, NOW())");
    $STH->bindParam(':name', $business["name"]);
    $STH->bindParam(':country', $business["country"]);
    $STH->bindParam(':email', $business["email"]);
    $STH->bindParam(':phone', $business["phone"]);
    $STH->bindParam(':website', $business["website"]);
    $STH->bindParam(':tagline', $business["tagline"]);
    $STH->bindParam(':category', $business["category"]);
    $STH->bindParam(':level', $business["level"]);
    $STH->bindParam(':writeup', $business["writeup"]);
    $STH->bindParam(':image', $business["image"]);
    $STH->execute();
    } catch(PDOException $e) {
    echo "bad times :(";
    //file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
    }
    ?>