At 6:04 PM -0400 4/12/10, Gary wrote:
For those that were looking to see a solution, this is what I have come up
with. It was pointed out on another board (MySQL) that inserting multiple
in one script is probably prohibited because of security reasons.
What I did was open the connection, insert into the table, close the
connection, close the php script, then start over again. This is the code:
$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting to
MySQL server');
$query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";
$result=mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
?>
<?php
$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting to
MySQL server');
$query="INSERT INTO address (street, town, state,
zip)"."VALUES('$street','$town','$state','$zip')";
$result=mysqli_query($dbc, $query)
or die('Error querying database.');
mysqli_close($dbc);
?>
It seems a little redundant for PHP, however it seems to work.
Thank you to everyone that responded. If by the way someone sees an issue
with this solution, I would love to read it.
Gary
Gary :
It not only looks redundant, but why two tables?
Why not "customers" or "users" or "subscribers" like so:
include(opendb.php);
$query="INSERT INTO users (first_name, last_name, street, town, state, zip)
VALUES('$first_name', '$last_name', $street', '$town', '$state', '$zip')";
$result=mysqli_query($dbc, $query) or die('Error querying database.');
include(closedb.php);
I don't see any reason to separate the attributes of the person into
two different tables. Why do that?
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php