Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. pdo php

pdo php

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpdatabasesaleshelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndyInUK
    wrote on last edited by
    #1

    Can anyone find an error in this query ?

    try {

    $dbh = new PDO(' ….. ');

    $stmt = $dbh->prepare('INSERT into customer (name) values (:name)');
    

    $stmt->bindParam(':name', 'lilly');
    $stmt->execute();

    $dbh = null;

    } catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "
    ";
    die();
    }

    It doesn't display any error and neither does it perform the insert?? Thanks

    A 1 Reply Last reply
    0
    • A AndyInUK

      Can anyone find an error in this query ?

      try {

      $dbh = new PDO(' ….. ');

      $stmt = $dbh->prepare('INSERT into customer (name) values (:name)');
      

      $stmt->bindParam(':name', 'lilly');
      $stmt->execute();

      $dbh = null;

      } catch (PDOException $e) {
      print "Error!: " . $e->getMessage() . "
      ";
      die();
      }

      It doesn't display any error and neither does it perform the insert?? Thanks

      A Offline
      A Offline
      Agecanonix
      wrote on last edited by
      #2

      Strange, when I run the code I get this error message: Fatal error: Cannot pass parameter 2 by reference in ... If you look at the PDOStatement::bindParam() documentation, the second argument is passed by reference, so I guess you can't pass a literal value by reference.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups