Update Query

Discussion in 'MySQL' started by Isaac, Jan 27, 2008.

  1. #1
    I added some info to my database, but gave them the wrong cat_id. I'm trying to update it, but the query doesn't seem to work. I'm trying to update all rows with a forum_id greater or equal to ( >= ) 4853 AND a cat_id of 11, AND a forum_sys of (Gameboy Advance).

    I ran a search in phpmyadmin with everything I just said I wanted above, and it returned all the rows I wanted. But when I try to make it update the cat_id, it affects no rows.

    Here is what I have:

    <?php
    mysql_connect("localhost", "****", "****") or die(mysql_error());
    echo "Connected to MySQL<br />";
    $sql = 'UPDATE `phpbb_forums` SET `cat_id` = 12 WHERE `forum_id` >= 4853 AND `cat_id` = 11 AND `forum_sys` LIKE CONVERT(_utf8 \'(Gameboy Advance)\' USING latin1) COLLATE latin1_swedish_ci' or die(mysql_error());
    mysql_query($sql)
    ?>
    
    Code (markup):
    It executes successfully, but affects no rows. Can anyone help me?
     
    Isaac, Jan 27, 2008 IP
  2. alphaduck

    alphaduck Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you send me in a pm, a larger of the section you were trying to edit, I need to see the entire, (more then this) to see how it fits into the db.

    Thanks
     
    alphaduck, Jan 27, 2008 IP
  3. jayasimha

    jayasimha Peon

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Do you have the update permission ?
     
    jayasimha, Jan 28, 2008 IP
  4. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    After connecting to mysql, you must select the database:

    mysql_select_db('my_database') or die("MySQL error : ".mysql_errno()." - ".mysql_error());
     
    CreativeClans, Jan 28, 2008 IP
  5. Isaac

    Isaac Peon

    Messages:
    389
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well just the query
    UPDATE `phpbb_forums` SET `cat_id` = 12 WHERE `forum_id` >= 4853 AND `cat_id` = 11 AND `forum_sys` LIKE CONVERT(_utf8 \'(Gameboy Advance)\' USING latin1) COLLATE latin1_swedish_ci
    Code (markup):
    doesn't work in phpmyadmin.
     
    Isaac, Jan 28, 2008 IP
  6. jayasimha

    jayasimha Peon

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What is the schema of your database ?
     
    jayasimha, Jan 29, 2008 IP
  7. Isaac

    Isaac Peon

    Messages:
    389
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    It's a regular phpbb forum database. I have added an extra field to phpbb_forums called "forum_sys" which is the same as "forum_desc".
     
    Isaac, Jan 29, 2008 IP