Advertisement
Guest User

response from my PDO Class... WTF?

a guest
Sep 3rd, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. "Array
  2. (
  3.    [:uid] => 1
  4.    [:content] => kjgrliueajrghkerg
  5.    [:ip_address] => 127.0.0.1
  6.    [:privacy] => 0
  7. )
  8. Array
  9. (
  10.    [ok] =>
  11.    [msg] => SQLSTATE[HY093]: Invalid parameter number: :content INSERT INTO s0cF_posts (user_id, post_content, ip_address, privacy) VALUES ( :uid, ':content', ':ip_address', :privacy )
  12. )
  13.  
  14. This is the post function that is returning this response:
  15.  
  16.     function post_status( $uid, $privacy, $content ) {
  17.         $content = pg_escape_string($content);
  18.         $ip = $_SERVER['REMOTE_ADDR'];
  19.         $prepared = $this->prepare( "INSERT INTO ".TP."_posts (user_id, post_content, ip_address, privacy) ".
  20.                                     "VALUES ( :uid, ':content', ':ip_address', :privacy )" );
  21.         $post_array = array(
  22.             ':uid'              => $uid,
  23.             ':content'      => $content,
  24.             ':ip_address'       => $ip,
  25.             ':privacy'          => $privacy );
  26.         print_r($post_array);
  27.         try {
  28.             $this->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  29.             $this->beginTransaction();
  30.             $prepared->execute( $post_array );
  31.             echo $prepared->queryString;
  32.             $post_id = $this->lastInsertId('post_id_seq');
  33.             $post_meta_array = array(
  34.             ':direct_link' => "posts/$uid/$post_id");
  35.             $prepared = $this->prepare( "INSERT INTO ".TP."_post_meta () ".
  36.                                         "VALUES ( 'direct_link', ':direct_link' )" );
  37.             $prepared->execute( $post_meta_array );
  38.         } catch ( PDOException $e ) {
  39.             $db_err = $e->getMessage();
  40.             $this->rollBack();
  41.             $response = array(
  42.                 'ok'    =>  false,
  43.                 'msg'   =>  $db_err." ".$prepared->queryString );
  44.             return $response;
  45.         }
  46.         $this->commit();
  47.         $response = array(
  48.             'ok'    =>  true,
  49.             'msg'   =>  "Success! $prepared->queryString" );
  50.         return $response;
  51.     }
  52.    
  53.         "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement