php - Inserting data to database returning as <br /> <font size='1'><table class='xdebug-error -


hi having problem whenever execute submit of form database. submit data form error instead of data inserted. index.php

<div id="postform">     <!-- username of user posting language learning object -->     <div id="postusername" data-role="field-contain">         <label for="username of user">username of user </label>         <input type="text" name="post_username" value="<?php echo $_session['post_username']; ?>" readonly="readonly" id="post_username"/>     </div>      <!-- word of language learning object -->     <div id="postword" data-role="field-contain">         <label for="word language learning object">word language learning object </label>         <input type="text" name="post_word" id="post_word" />     </div>      <!-- description of word -->     <div id="postdescription" data-role="field-contain">         <label for="word description">word description </label>         <textarea name="word_description" id="word_description"></textarea>     </div>      <!-- categorization of given word -->     <div id="postcategorization" data-role="field-contain">         <label for="categorization of word">categorization of word </label>         <select name="word_categorization" id="word_categorization">             <option value=""> select </option>             <option value="adverb"> adverb </option>             <option value="adjective"> adjective </option>             <option value="noun"> noun </option>             <option value="verb"> verb </option>         </select>     </div>      <!-- origin of given word -->     <div id="postorigin" data-role="field-contain">         <label for="origin of word">origin of word </label>         <input type="text" name="word_origin" id="word_origin" />     </div>      <!-- getting user's location -->     <div id="userlocation" data-role="field-contain">         <label for="user location">user location</label>         <input type="text" name="user_loc" value="<?php echo $geo->city;?>" />     </div>      <!-- submit button -->     <div id="submitpost" data-role="field-contain">         <button name="submit_post" type="submit" id="submit_post">create post</button>     </div> </div> <!-- end of form --> 

post.php

<?php  include_once( 'connect.php' );  class managepost {      protected $link;      /* connection database */     function __construct(){         $db_connect = new managedatabase;         $this->link = $db_connect->databaseconnect();         return $this->link;     }      /* creating language learning objects/posts */     function addpost($username,$word,$description,$categorization,$origin,$user_loc,$date,$time) {         $query = $this->link->prepare("insert post (username, word, description, categorization, origin, user_loc, date, time) values (?,?,?,?,?,?,?,?)");             $values = array($username,$word,$description,$categorization,$origin,$user_loc,$date,$time);          $query->execute($values);         $rowcount = $query->rowcount();          return $rowcount;     } } 

dbpost.php

<?php      session_start();     include('../class/post.php');     $post_init = new managepost;      if($_post)     {         $username           = $_post['post_username'];         $word               = $_post['post_word'];         $description        = $_post['word_description'];         $categorization     = $_post['word_categorization'];         $origin             = $_post['word_origin'];         $user_loc           = $_post['user_loc'];         $date               = date("y-m-d");         $time               = date ("h:i:s");          $submit_post = $post_init->addpost($username, $word, $description, $categorization, $origin, $user_loc, $date, $time);          if($submit_post == 1)         {             echo 'true';         }         else         {             echo 'failed submit';         }     } ?> 

createpost.js

$('form').submit(function() {      if(validateword() && validatedescription() && validatecategorization() &&  validateorigin())     {         $.post('lib/dbpost.php', $('form').serialize(), function(response) {             if(response == 'true')             {                 showsuccess('post submitted');             }             else             {                 showerror(response);             }         })     } }); 

when check table post in phpmyadmin shows errors

<br /><font size='1'><table class='xdebug-error xe  

in attributes

"word, description, origin, , user_loc" 

can try changing add_post function shown below:

function addpost($username, $word, $description, $categorization, $origin, $user_loc, $date,$time){     $query = $this->link->prepare("insert post (username,word,description,categorization,origin,user_loc,date,time)     values (:username,:word,:description,:categorization,:origin,:user_loc,:date,:time)");     $query->bindparam(':username', $username);     $query->bindparam(':word', $word);     $query->bindparam(':description', $description);     $query->bindparam(':categorization', $categorization);     $query->bindparam(':origin', $origin);     $query->bindparam(':user_loc', $user_loc);     $query->bindparam(':date', $date);     $query->bindparam(':time', $time);     $query->execute();     $rowcount = $stmt->rowcount();     return $rowcount; } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -