From: Reindl Harald Date: April 15 2011 4:16pm Subject: Re: Out of sync tables List-Archive: http://lists.mysql.com/mysql/224812 Message-Id: <4DA86F4E.2060402@thelounge.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9E3637A40D907CF313961549" --------------enig9E3637A40D907CF313961549 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Am 15.04.2011 17:59, schrieb Gary: > Michael, thank you for your reply >=20 > ""Might I suggest, instead of the 2 part juggling act, you drop the > auto-increment property on your second table, and just use the value > derived from the first as the joining key in the second. Then there > is only one sequence to worry about with nothing to sync against > "" >=20 > There is only one AI into the main page. This is the insert code, I ha= ve=20 > probably left more in than you need to see. >=20 > What I also did was to add some duplicate columns in the two tables (em= ail,=20 > ip, timestamp) so in the event I need to manually to in I would be able= to=20 > decifer who goes where. >=20 > On second look, it would appear I am NOT using a join, but two inserts.= =2E.. I=20 > don't recall why I did it that way this code is unreadable for me because of its coding-style and if i see "addslashes" for database inserts i start to fear and run away you are using two inserts so what do you do there and where can be anythi= ng out of sync on the database-level? where is the magic in your code withou= t using mysql_insert_id() or LAST_INSERT_ID() - what should this code do? * insert in main table * fetch mysql_insert_id() what is thread-safe * use that value in the second table ____________ and please do not use such ugly hacks as in the begin of your code addslashes() has no useable security for user-input even mysql_escape_string() has not -> mysql_real_escape_string() --------------enig9E3637A40D907CF313961549 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk2ob04ACgkQhmBjz394Ann8YwCfd6vMflIiqASJ9uqhZgdZftfa IMUAoIPat24Q9JAhg4qtLS/Y+3oXwmCH =kT4v -----END PGP SIGNATURE----- --------------enig9E3637A40D907CF313961549--