List:General Discussion« Previous MessageNext Message »
From:Gary Date:April 11 2010 4:57pm
Subject:INSERT INTO multiple tables
View as plain text  
I am experimenting with multiple tables, it is only a test that is my local
machine only. This is the current code, which does not work , I have tried
to concatonate the insert statements.  I have tried multiple $query
variables, but it is just overwriting itself (only the last one gets
inserted). I also tried writing the $query as an array, which got me an
error message (saying it was expecting a string and I offered an array).

Someone point me in the right direction?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">

<label>First Name </label> <input name="fname" type="text" /><br
/><br />
<label>Last Name </label><input name="lname" type="text" /><br
/><br />
<label>Street Address </label><input name="street" type="text" /><br
<label>Town </label><input name="town" type="text" /><br /><br
<label>State </label><input name="state" type="text" /><br
/><br />
<label>Zip Code</label><input name="zip" type="text" /><br
/><br />
<label>Telephone</label><input name="phone" type="text" /><br
/><br />
<label>Fax</label><input name="fax" type="text" /><br /><br
<label>E-Mail</label><input name="email" type="text" /><br
/><br />
<label>Comments</label><br /><textarea name="comments" cols="100"
rows="15"></textarea><br /><br />

<input name="submit" type="submit" value="submit" />



$query="INSERT INTO address (street, town, state,
"INSERT INTO comments(comments)"."VALUES('$comments')".
"INSERT INTO contact(phone,fax,email)"."VALUES('$phone','$fax','$email')".
"INSERT INTO name (fname, lname)"."VALUES('$fname','$lname')";

$result = mysqli_query($dbc, $query)
or die('Error querying database.');



__________ Information from ESET Smart Security, version of virus signature database 5017
(20100411) __________

The message was checked by ESET Smart Security.

INSERT INTO multiple tablesGary11 Apr
  • Re: INSERT INTO multiple tablesviraj12 Apr
    • Re: INSERT INTO multiple tablesColin Streicher12 Apr
  • Re: INSERT INTO multiple tablesGary12 Apr
    • Re: INSERT INTO multiple tablesMichael Dykman12 Apr
  • Re: INSERT INTO multiple tablesGary12 Apr
    • Re: INSERT INTO multiple tablesColin Streicher13 Apr
    • Re: INSERT INTO multiple tablesChris W13 Apr
  • Re: INSERT INTO multiple tablesGary13 Apr
  • Re: INSERT INTO multiple tablesGary13 Apr