<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1054426" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1054426</link>
    <description></description>
    <language>en</language>
          <item>
    <title>We can done it by using</title>
    <link>https://www.webmaster-forums.net/web-database-development/inserting-data-multiple-tables-mysql-using-php#comment-1284269</link>
    <description> &lt;p&gt;We can done it by using database connectivity code in php i.e. mysql_connect(); after the clicking on the submit button, the data transfer on multiple tables.&lt;/p&gt;
 </description>
     <pubDate>Wed, 24 Apr 2013 06:02:19 +0000</pubDate>
 <dc:creator>RohanJaiswal</dc:creator>
 <guid isPermaLink="false">comment 1284269 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>On the basic level, the code</title>
    <link>https://www.webmaster-forums.net/web-database-development/inserting-data-multiple-tables-mysql-using-php#comment-1280803</link>
    <description> &lt;p&gt;On the basic level, the code looks like it would work, below is what I would have done given the code you presented.&lt;/p&gt;
&lt;p&gt;1. If not already done so, variables affected by the web user need to be escaped so that if they enter don&#039;t know as an entry, it won&#039;t break your query.&lt;/p&gt;
&lt;p&gt;2. Guessing that you are not needing the SQL statement or results else where, you can simply recycle the variable named.&lt;/p&gt;
&lt;p&gt;3. The way you had it working on the error checking, if the first query failed yet the second one went fine, you would not have seen the error, as mysql_error() gives you the results from the last query executed. As it is good to get into the practice of all data handling being done BEFORE any actual output (makes the output code a lot easier to work with), I put the die() statements right up with the query, so the script will stop at the right spot, not in the middle of code. To be honest, once live they should really never fire. If there is a possible issue of insert errors, say ICnum is a primary key, so you can&#039;t have duplicates, you should be doing a query beforehand to check to see if it exists, and either nicely error to the user, or do an update instead)&lt;/p&gt;
&lt;p&gt;4. Assuming that $studentDetails and $kpp variables are NOT somehow set user, it is good practice to get used to wrapping all table names/fieldnames with the correct type of (basically) quoting method, the backtick (NOT a single quote, on PC&#039;s the key to the left of the 1 key, above TAB). Once you get used to it, it really ends up not being much extra. Also, just in case $kpp is something like  &quot;database.table&quot; instead of just &quot;table&quot;, note the following code would not work, each item needs wrapped... ex  `database`.`table` not `database.table` &lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;// If not already handled somewhere else, each variable MUST have the following applied to it, do NOT use addslashes&lt;br /&gt;$IC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($IC);&lt;br /&gt;$name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($name);&lt;br /&gt;$sex&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($sex);&lt;br /&gt;$address&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($address);&lt;br /&gt;$phonenum1 = mysql_real_escape_string($phonenum1);&lt;br /&gt;$phonenum2 = mysql_real_escape_string($phonenum2);&lt;br /&gt;$type&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($type);&lt;br /&gt;$date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($date);&lt;br /&gt;$deposit&amp;nbsp;&amp;nbsp; = mysql_real_escape_string($deposit);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;$sql = &amp;quot;INSERT INTO `$studentDetails` VALUES (&amp;#039;$IC&amp;#039;,&amp;#039;$name&amp;#039;,&amp;#039;$sex&amp;#039;,&amp;#039;$address&amp;#039;,&amp;#039;$phonenum1&amp;#039;,&amp;#039;$phonenum2&amp;#039;,&amp;#039;$type&amp;#039;,&amp;#039;$date&amp;#039;,&amp;#039;$deposit&amp;#039;,&amp;#039;$totalFee&amp;#039;)&amp;quot;;&lt;br /&gt;$result = mysql_query($sql,$conn)	or die(&amp;#039;[ERR:&amp;#039;.__LINE__.&amp;#039;]: &amp;#039;.mysql_error());&lt;br /&gt;&lt;br /&gt;$sql = &amp;quot;INSERT INTO `$kpp` (`ICnum`,`licenseType`,`dateRegistered`,`totalFee`,`remainingAmount`) VALUES (&amp;#039;$IC&amp;#039;,&amp;#039;$type&amp;#039;,&amp;#039;$date&amp;#039;,&amp;#039;$totalFee&amp;#039;,&amp;#039;$answer&amp;#039;)&amp;quot;;&lt;br /&gt;$result = mysql_query($sql,$conn)	or die(&amp;#039;[ERR:&amp;#039;.__LINE__.&amp;#039;]: &amp;#039;.mysql_error());&lt;br /&gt;&lt;br /&gt;// At this point it would have DIEd out if there was error...&lt;br /&gt;printf(&amp;quot;window.alert (\&amp;quot;New record added!\&amp;quot;);&amp;quot;);&lt;br /&gt;include &amp;quot;AddNewRecord.html&amp;quot;;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 30 Sep 2012 10:45:59 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1280803 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
