mysql_query

------=_NextPart_000_0011_01CA1971.25BEF1B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have the syntax

mysql_query("INSERT INTO ....);");

If this is successful I want to do update a column in one of my tables

$query =3D "UPDATE ... ";
mysql_query($query);

How do I test if the INSERT INTO mysql_query, in order to trigger the =
UPDATE?

Ron

------=_NextPart_000_0011_01CA1971.25BEF1B0--
Ron Piggott [ Mo, 10 August 2009 10:15 ] [ ID #2011693 ]

Re: mysql_query

Ron Piggott wrote:

> I have the syntax
>
> mysql_query("INSERT INTO ....);");
>
> If this is successful I want to do update a column in one of my tables
>
> $query = "UPDATE ... ";
> mysql_query($query);
>
> How do I test if the INSERT INTO mysql_query, in order to trigger the
> UPDATE?
>
> Ron

You could check the mysql section of the documentation, where you will find
http://php.net/manual/en/function.mysql-affected-rows.php which will tell
you how many rows were affected by your INSERT. Alternatively, if you are
using Innodb tables, you could look at using transactions.


Cheers
--
David Robley

Those who can't write, write help files.
Today is Boomtime, the 3rd day of Bureaucracy in the YOLD 3175.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
David Robley [ Mo, 10 August 2009 10:57 ] [ ID #2011694 ]

Re: mysql_query

On Aug 10, 2009, at 4:15 AM, "Ron Piggott"
<ron.php [at] actsministries.org> wrote:

> I have the syntax
>
> mysql_query("INSERT INTO ....);");
>
> If this is successful I want to do update a column in one of my tables
>
> $query = "UPDATE ... ";
> mysql_query($query);
>
> How do I test if the INSERT INTO mysql_query, in order to trigger
> the UPDATE?
>
> Ron

You could use the REPLACE syntax in mysql

http://dev.mysql.com/doc/refman/5.0/en/replace.html

Bastien

Sent from my iPod

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Phpster [ Mo, 10 August 2009 13:49 ] [ ID #2011695 ]
PHP » gmane.comp.php.database » mysql_query

Vorheriges Thema: adding a simple WHERE clause to this MySQL query causes the result to contain 0 rows?!
Nächstes Thema: Code optimization