SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am not able to update the contents of my table. Below is a list of commands and their results so that you can see what exactly I am doing. Any ideas whay I can't upadate it?

    Thank you very much


    mysql> create table sample_table(
    -> id int not null auto_increment primary key,
    -> testtext text,
    -> testdate date not null
    -> );

    Query OK, 0 rows affected (0.00 sec)




    mysql> describe sample_table;
    +----------+---------+------+-----+------------+----------------+---------------------------------+
    | Field | Type | Null | Key | Default | Extra | Privileges |
    +----------+---------+------+-----+------------+----------------+---------------------------------+
    | id | int(11) | | PRI | NULL | auto_increment | select,insert,update,references |
    | testtext | text | YES | | NULL | | select,insert,update,references |
    | testdate | date | | | 0000-00-00 | | select,insert,update,references |
    +----------+---------+------+-----+------------+----------------+---------------------------------+
    3 rows in set (0.00 sec)





    mysql> select id, testtext, testdate from sample_table;
    +----+-------------------+------------+
    | id | testtext | testdate |
    +----+-------------------+------------+
    | 1 | text to test it | 2000-08-02 |
    | 2 | number2 test text | 2000-02-22 |
    +----+-------------------+------------+
    2 rows in set (0.00 sec)




    mysql> update sample_table set testtext="new text", testdate="2000-07-07" where id=1;
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 0 Changed: 0 Warnings: 0




    mysql> select id, testtext, testdate from sample_table;
    +----+-------------------+------------+
    | id | testtext | testdate |
    +----+-------------------+------------+
    | 1 | text to test it | 2000-08-02 |
    | 2 | number2 test text | 2000-02-22 |
    +----+-------------------+------------+
    2 rows in set (0.00 sec)

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    update sample_table set testtext="new text", testdate="2000-07-07" where id=1

    should be

    update sample_table set testtext = 'new text', testdate = '2000-07-07' where id = 1;
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope, doesn't help:(

    below is what I typed in case I did sth wrong

    thank you

    mysql> update sample_table set testtext='new text attempt', testdate='2000-07-07' where id=1;
    Query OK, 0 rows affected (0.00 sec)
    Rows matched: 0 Changed: 0 Warnings: 0

    mysql> select id,testtext,testdate from sample_table;
    +----+-------------------+------------+
    | id | testtext | testdate |
    +----+-------------------+------------+
    | 1 | text to test it | 2000-08-02 |
    | 2 | number2 test text | 2000-02-22 |
    +----+-------------------+------------+
    2 rows in set (0.00 sec)

  4. #4
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try putting a space on both sides of your equals sign. Then it should work. I'm not sure if you have to though.

    Try just copying and pasting what freddydoesphp typed that way it will be right for sure.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The command
    update sample_table set testtext="new one" where testtext="text to test it";
    works "perfect", but when I try to update using the primary key, it doesn't work:(

    I am just getting more and more crazy every other second it goes like this:((( because all these commands works perfect with my other server.

    The output of the command:

    update sample_table set testtext="new one" where testtext="text to test it";
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1 Changed: 1 Warnings: 0

    mysql> select id, testtext, testdate from sample_table;
    +----+-------------------+------------+
    | id | testtext | testdate |
    +----+-------------------+------------+
    | 1 | new one | 2000-08-02 |
    | 2 | number2 test text | 2000-02-22 |
    +----+-------------------+------------+
    2 rows in set (0.00 sec)


  6. #6
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could it be that your username doesn't have the correct permissions?

    e.g. when you setup your username you didn't use

    "GRANT SELECT,INSERT,UPDATE,DELETE" etc etc

    btw; I am not too good when it comes to SQL; this is just a thought...

  7. #7
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am the root:)


Bookmarks

Posting Permissions

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