Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert into two tables does not insert into the last table . pdo
    primarykey
    data
    text
    <p>I am trying to insert into two different tables but the last table does not receive the data. There is no error displayed I really do not know what might be the cause of this situation. Is it because the second table contain a foreign key ?</p> <pre><code>&lt;?php #connect to the db require_once('db.inc.php'); ?&gt; &lt;?php $date_created = date('y-m-d h:i:s a'); $username = (isset($_POST['username'])) ? trim($_POST['username']) : ''; $Previllage = (isset($_POST['Previllage'])) ? trim($_POST['Previllage']) : ''; #second tanble values $title = (isset($_POST['title'])) ? trim($_POST['title']) : ''; $firstname = (isset($_POST['firstname'])) ? trim($_POST['firstname']) : ''; $lastname = (isset($_POST['lastname'])) ? trim($_POST['lastname']) : ''; $client_code = (isset($_POST['client_code'])) ? trim($_POST['client_code']) : ''; #end $query = "INSERT INTO tish_user(username,Previllage,date_created) VALUES(:username,:Previllage,:date_created)"; $insert = $con-&gt;prepare($query); $insert-&gt;execute(array(':username' =&gt; $username, ':Previllage' =&gt; $Previllage, 'date_created' =&gt; $date_created)); # try another insert $query = "INSERT INTO tish_clientinfor(title,firstname,lastname,client_code,date_registered) VALUES(:title,:firstname,:lastname,:client_code,:date_registered)"; $insert = $con-&gt;prepare($query); $insert-&gt;execute(array( ':title' =&gt; $title, ':firstname' =&gt; $firstname, ':lastname' =&gt; $lastname, ':client_code' =&gt; $client_code, 'date_registered' =&gt; $date_created)); ?&gt; </code></pre>
    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.
    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