Results 1 to 4 of 4

Thread: problem updating database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    problem updating database

    I don't understand where I'm going wrong in this:
    PHP Code:
    for($j=1$j<=18$j++){
        
    $sql "UPDATE boti_pages SET chapter = '".$chapTitles[$j][0]."' WHERE page_num >= '".$chapTitles[0][$j]."' AND page_num < '".$chapTitles[0][$j+1]."'";
    echo 
    $sql."<br />";

    PHP Code:
    $chapTitles[1][0] = "Introduction"
    $chapTitles[0][1] =  "1";

    $chapTitles[2][0] = "chapter 1";
    $chapTitles[0][2] =  "5";

    $chapTitles[3][0] = "chapter 2"
    $chapTitles[0][3] =  "17";

    $chapTitles[4][0] = "chapter 3";
    $chapTitles[0][4] =  "18";

    $chapTitles[5][0] = "chapter 4";
    $chapTitles[0][5] =  "27";

    $chapTitles[6][0] = "chapter 5";
    $chapTitles[0][6] =  "48"
    Echo-ing the SQL I get:
    UPDATE boti_pages SET chapter = 'Introduction' WHERE page_num >= '1' AND page_num < '5'
    UPDATE boti_pages SET chapter = 'chapter 1' WHERE page_num >= '5' AND page_num < '17'
    UPDATE boti_pages SET chapter = 'chapter 2' WHERE page_num >= '17' AND page_num < '18'
    UPDATE boti_pages SET chapter = 'chapter 3' WHERE page_num >= '18' AND page_num < '27'
    UPDATE boti_pages SET chapter = 'chapter 4' WHERE page_num >= '27' AND page_num < '48'
    UPDATE boti_pages SET chapter = 'chapter 5' WHERE page_num >= '48' AND page_num < '62'
    But there is no entry into the database in the chapter field.
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: problem updating database

    You don't seem to be executing your SQL statements?


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Posts
    447

    Re: problem updating database

    I forgot to include:
    $result = mysql_query($sql) OR exit( 'Error: ' . mysql_error() );
    Compare bible texts (and other tools):
    TheWheelofGod

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: problem updating database

    You mean you forgot to include in what you posted above? Or had you forgotten in your code and now you added it and it works?


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

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



Click Here to Expand Forum to Full Width