php & mysql update problem

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default php & mysql update problem

    Dear news-team

    I'm using MySQL 4.0.15a (with PHP 4.3.4rc1 and Apache 2.0.47 under FreeBSD).

    I'm having problems when updating a column of a table (it updates an extra
    column).

    As an example, I provide this sample (data_registre, data_ultima_connexio are
    the outputs of the SELECT).

    ** UPDATE usuaris SET data_ultima_fallada = 'NULL' WHERE userid = 'test'
    ** SELECT * FROM usuaris WHERE userid = 'test'
    --> data_registre 20031120231019
    --> data_ultima_connexio 20031120231019

    ** UPDATE usuaris SET data_ultima_connexio = '20031120231112' WHERE userid =
    'test'
    ** SELECT * FROM usuaris WHERE userid = 'test'
    --> data_registre 20031120231112
    --> data_ultima_connexio 20031120231112

    The PHP statements are exactly those that begin with **, and --> shows a
    subset of a results received.


    As you can see, the last update modifies both data_registre and
    data_ultima_connexio. These updates and selects run alone and in sequential
    mode, so data_registre should be always the same.

    I really don't figure where is the problem. Moreover I add the table definition.

    CREATE TABLE usuaris (userid VARCHAR(16),
    nom_complet VARCHAR(64) NOT NULL,
    correu VARCHAR(64) NOT NULL,
    data_registre TIMESTAMP(14) NOT NULL,
    data_ultima_connexio TIMESTAMP(14),
    data_ultima_fallada TIMESTAMP(14),
    paraula_de_pas VARCHAR(32) NOT NULL,
    privilegis VARCHAR(255),
    fallades INTEGER NOT NULL,
    PRIMARY KEY (userid));

    Has anyone any idea that could solve this problem?

    Thanks in advance.

    --
    __________________________________________________ ______________________
    Harald Servat Gelabert (harald at cepba dot upc dot es)
    o//o Centre Europeu de Paral.lelisme de Barcelona CEPBA
    o//o [url]WWW...:[/url] [url]http://www.cepba.upc.es[/url] Tel: +34-93-401 74 23
    o//o e-mail: [email]suport@cepba.upc.es[/email] Fax: +34-93-401 25 77
    o//o CEPBA c/Jordi Girona, 1-3, Ṃdul D6. E-08034 Barcelona, Catalunya
    __________________________________________________ ______________________

    The fundamental difference between Unix and Macintosh operating system
    is that Unix was designed to please programmers, whereas the Mac was
    designed to please users. (Windows, on the other hand, was designed to
    please accountants, but that's another story)
    -- from The UNIX haters handbook, page 163
    Harald Servat Gelabert Guest

  2. Similar Questions and Discussions

    1. MySql UPDATE problem with duplicate rows
      Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary...
    2. flash > php > mySQL update query problem
      Hi all! Bit of an urgent problem. I am trying to update a mySQL database via flash and PHP where two variables are supplied, a name and a contact...
    3. Can I do MySQL 4.1 -> 5.1 update just like this?
      My phpBB version is 2.0.19. Can I do MySQL 4.1 -> 5.1 update just like this: 1.. Export phpbb -table with phpMyAdmin (SQL-options ...
    4. Flash - PHP - mySQL - update databse records problem
      Hi i am having troubnle getting flash to update existing databse records. I can get it to add new records and view existing records buit cant get it...
    5. HOW TO -- ARRAY UPDATE MYSQL
      HI ALL, I want to update a mulitple row from a HTML Table to MYSQL Database. L1 V1 T1 L2 V2 V2 L3 V3 V3 Any help in this regard is much...
  3. #2

    Default Re: php & mysql update problem


    On 21-Nov-2003, Harald Servat Gelabert <harald@cepba.upc.es> wrote:
    > I'm using MySQL 4.0.15a (with PHP 4.3.4rc1 and Apache 2.0.47 under
    > FreeBSD).
    >
    > I'm having problems when updating a column of a table (it updates an extra
    > column).
    >
    > As an example, I provide this sample (data_registre, data_ultima_connexio
    > are
    > the outputs of the SELECT).
    >
    > ** UPDATE usuaris SET data_ultima_fallada = 'NULL' WHERE userid = 'test'
    > ** SELECT * FROM usuaris WHERE userid = 'test'
    > --> data_registre 20031120231019
    > --> data_ultima_connexio 20031120231019
    >
    > ** UPDATE usuaris SET data_ultima_connexio = '20031120231112' WHERE
    > userid =
    > 'test'
    > ** SELECT * FROM usuaris WHERE userid = 'test'
    > --> data_registre 20031120231112
    > --> data_ultima_connexio 20031120231112
    >
    > The PHP statements are exactly those that begin with **, and --> shows a
    > subset of a results received.
    >
    >
    > As you can see, the last update modifies both data_registre and
    > data_ultima_connexio. These updates and selects run alone and in
    > sequential
    > mode, so data_registre should be always the same.
    >
    > I really don't figure where is the problem. Moreover I add the table
    > definition.
    >
    > CREATE TABLE usuaris (userid VARCHAR(16),
    > nom_complet VARCHAR(64) NOT NULL,
    > correu VARCHAR(64) NOT NULL,
    > data_registre TIMESTAMP(14) NOT NULL,
    > data_ultima_connexio TIMESTAMP(14),
    > data_ultima_fallada TIMESTAMP(14),
    > paraula_de_pas VARCHAR(32) NOT NULL,
    > privilegis VARCHAR(255),
    > fallades INTEGER NOT NULL,
    > PRIMARY KEY (userid));
    >
    > Has anyone any idea that could solve this problem?
    TIMESTAMP columns are automatically updated whenever you modify the row.
    Change the TIMESTAMP columns to DATETIME.

    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    tom (at) creative (dash) light (dot) com
    do NOT send email to [email]jamesbutler@willglen.net[/email] (it's reserved for spammers)
    Tom Thackrey Guest

  4. #3

    Default Re: php & mysql update problem

    Your problem is in the design of your database table. MySQL has the
    special property that the first column of TIMESTAMP datatype will
    automatically be updated when a record is changed with the UPDATE DML
    statement. My suggestion is to add a date_modified column before the
    data_registre column and you can choose to ignore but it will solve
    your problem.

    Wes
    > Harald Servat Gelabert <harald@cepba.upc.es> wrote in message news:
    > <3FBDE2E4.952EB49E@cepba.upc.es>...
    > Dear news-team
    >
    > I'm using MySQL 4.0.15a (with PHP 4.3.4rc1 and Apache 2.0.47 under FreeBSD).
    >
    > I'm having problems when updating a column of a table (it updates an extra
    > column).
    >
    > As an example, I provide this sample (data_registre, data_ultima_connexio are
    > the outputs of the SELECT).
    >
    > ** UPDATE usuaris SET data_ultima_fallada = 'NULL' WHERE userid = 'test'
    > ** SELECT * FROM usuaris WHERE userid = 'test'
    > --> data_registre 20031120231019
    > --> data_ultima_connexio 20031120231019
    >
    > ** UPDATE usuaris SET data_ultima_connexio = '20031120231112' WHERE userid =
    > 'test'
    > ** SELECT * FROM usuaris WHERE userid = 'test'
    > --> data_registre 20031120231112
    > --> data_ultima_connexio 20031120231112
    >
    > The PHP statements are exactly those that begin with **, and --> shows a
    > subset of a results received.
    >
    >
    > As you can see, the last update modifies both data_registre and
    > data_ultima_connexio. These updates and selects run alone and in sequential
    > mode, so data_registre should be always the same.
    >
    > I really don't figure where is the problem. Moreover I add the table definition.
    >
    > CREATE TABLE usuaris (userid VARCHAR(16),
    > nom_complet VARCHAR(64) NOT NULL,
    > correu VARCHAR(64) NOT NULL,
    > data_registre TIMESTAMP(14) NOT NULL,
    > data_ultima_connexio TIMESTAMP(14),
    > data_ultima_fallada TIMESTAMP(14),
    > paraula_de_pas VARCHAR(32) NOT NULL,
    > privilegis VARCHAR(255),
    > fallades INTEGER NOT NULL,
    > PRIMARY KEY (userid));
    >
    > Has anyone any idea that could solve this problem?
    >
    > Thanks in advance.
    >
    > --
    > __________________________________________________ ______________________
    > Harald Servat Gelabert (harald at cepba dot upc dot es)
    > o//o Centre Europeu de Paral.lelisme de Barcelona CEPBA
    > o//o [url]WWW...:[/url] [url]http://www.cepba.upc.es[/url] Tel: +34-93-401 74 23
    > o//o e-mail: [email]suport@cepba.upc.es[/email] Fax: +34-93-401 25 77
    > o//o CEPBA c/Jordi Girona, 1-3, Ṃdul D6. E-08034 Barcelona, Catalunya
    > __________________________________________________ ______________________
    >
    > The fundamental difference between Unix and Macintosh operating system
    > is that Unix was designed to please programmers, whereas the Mac was
    > designed to please users. (Windows, on the other hand, was designed to
    > please accountants, but that's another story)
    > -- from The UNIX haters handbook, page 163
    Wes Bailey Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139