Note that there are some explanatory texts on larger screens.

plurals
  1. POunexpected error on inserting values and error with implode()
    primarykey
    data
    text
    <p>I am inserting the values using <code>PDO</code> but i am getting error as:</p> <p><code>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,price,nick_name,gender,size,color,birth_date,uname,uphone,ucountry,ustate,u' at line 1' in C:\wamp\www\aa\abc.php:58 Stack trace: #0 C:\wamp\www\www\aa\abc.phpphp(58): PDOStatement-&gt;execute(Array) #1 {main} thrown in C:\wamp\www\www\aa\abc.php.php on line 58</code></p> <p>also getting <code>Warning: implode() [function.implode]: Bad arguments</code> for implode function</p> <p>Code:</p> <pre><code>foreach ($_POST['pcheck'] as $p_check) ////storing checkbox values { $pcheckp[] = $p_check; } $finalcheck = implode(',', $pcheck); foreach ($_POST['pinc'] as $p_inc) ////storing inputfield values { $pinc[] = $p_inc; } $finalpinc = implode(',', $pinc); $sql = "INSERT INTO list (u_id,list_type,list_ff,breed,title,desc,price,nick_name,gender,size,color,birth_date,uname,uphone,ucountry,ustate,ucity,usite,pcheck,pinc,photo) VALUES(:uid,:list_type,:list_ff,:breed,:title,:desc,:price,:nick_name,:gender,:size,:color,:date,:uname,:uphone,:ucountry,:ustate,:ucity,:usite,:pcheck,:pinc,:p_photo)"; $q = $db-&gt;prepare($sql); $q-&gt;execute(array(':uid'=&gt;dd, ':list_type'=&gt;$list_type, ':breed'=&gt;$breed, ':title'=&gt;$title, ':desc'=&gt;$desc, ':price'=&gt;$price, ':list_ff'=&gt;$list_ff, ':nick_name'=&gt;$nick_name, ':gender'=&gt;$gender, ':size'=&gt;$size, ':color'=&gt;$color, ':date'=&gt;$date, ':uname'=&gt;$uname, ':uphone'=&gt;$uphone, ':ucountry'=&gt;$ucountry, ':ustate'=&gt;$ustate, ':ucity'=&gt;$ucity, ':usite'=&gt;$usite, ':pcheck'=&gt;$finalcheck, ':pinc'=&gt;$finalpinc, ':p_photo'=&gt;$p_photo)); </code></pre> <p><code>$_POST['pcheck']</code> and <code>$_POST['pinc']</code> is used to get checkbox and input values which i am going to store in column in mysql.</p> <p>I have checked many times to find the syntax error in insert query but nothing wrong is in it</p> <p>Hoping to get help Thanks! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload