SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Notice: Undefined offset: 1

    And a few other errors, notices and warnings.
    Notice: Undefined offset: 0 in ...create_bible.php on line 102
    INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('1', '1', 'gn', 'Genesis', '1', '1', '1', '1', 'In the beginning God created the heaven and the earth.')

    Notice: Undefined offset: 1 in ...create_bible.php on line 119

    Warning: array_slice() expects parameter 1 to be array, null given in ...create_bible.php on line 119

    Warning: implode() [function.implode]: Invalid arguments passed in ...create_bible.php on line 119
    INSERT INTO bible (book, book_spoke, recordType, book_title, chapter, chapter_spoke, verse, verse_spoke, text_data) VALUES ('')
    PHP Code:
        $file="saveddbtable/bible.htm";
        
    $contents_of_page file_get_contents($file);
        
    $dom = new DOMDocument();
        
    $dom->loadHTML($contents_of_page);
        
    // Initialize arrays
        
    $thArray $tdArray $array = array();
        
    // Get all Table Headers and throw them in an array
        
    $th $dom->getElementsByTagName('th');
        foreach ( 
    $th as $th ){
            
    $thArray[] = $th->nodeValue;
        }
        
    // count the array for future comparison
        
    $count count($thArray);
        
    /* Example:
        Array(
        [0] => Unit Type
        [1] => Availability
        [2] => Rates
        )
        */
        // Get all the Table Cells, but if it matches the same count as the Table Header array, create a new array row
        
    $td $dom->getElementsByTagName('td');
        
    $i 0;
        foreach( 
    $td as $td_field ){
            if(
    count($tdArray[$i]) != $count){
                
    $tdArray[$i][] = $td_field->nodeValue;
            }else{
                
    $i++;
                if(
    $i=50){
                    break;
                }
                
    $tdArray[$i][] = $td_field->nodeValue;
            }

        }
        
    $numRecordsPerPage 50;
        
    $offset $numRecordsPerPage * ($page 1);
        
    //$tdarr = implode("', '", array_slice($tdArray[0], 1));
        
        
    for($j $offset$j $offset $numRecordsPerPage$j++){
            
    // Add to insert statement
            
    $tdarr implode("', '"array_slice($tdArray[$j], 1));
            
    $sql "INSERT INTO ".$dbTable3." (".$fieldarr.") VALUES ('".$tdarr."')";
            echo 
    "<span style=\"color: green;\">".$sql."</span><br />\n";
            
    //mysql_query($sql) or die(mysql_error());
        
    }
    /*echo '<pre>';
    //print_r(array_combine($thArray, $tdArray));
    print_r($thArray);
    print_r($tdArray);
    echo '</pre>';*/ 
    Compare bible texts (and other tools):
    TheWheelofGod

  2. #2
    SitePoint Zealot xzyfer's Avatar
    Join Date
    Mar 2004
    Location
    oz
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you supply the bible.htm so we can debug this code for ourselves, it's quite hard to follow the code you've given

  3. #3
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to show the entire code. That php code you've shown is pretty much useless as there is no where near 120 lines of code there. Unless we can see all of it there is no way for us to see what is going wrong.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  4. #4
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code HTML4Strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Bible Small Sample</title>
    </head>
     
    <body><table><tr><th>id</th><th>book</th><th>book_spoke</th><th>recordType</th><th>book_title</th><th>chapter</th><th>chapter_spoke</th><th>verse</th><th>verse_spoke</th><th>text_data</th></tr><tr><td>1</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>1</td><td>1</td><td>In the beginning God created the heaven and the earth.</td></tr><tr><td>2</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>2</td><td>2</td><td>And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.</td></tr><tr><td>3</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>3</td><td>3</td><td>And God said, Let there be light: and there was light.</td></tr><tr><td>4</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>4</td><td>4</td><td>And God saw the light, that it was good: and God divided the light from the darkness.</td></tr><tr><td>5</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>5</td><td>5</td><td>And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.</td></tr><tr><td>6</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>6</td><td>6</td><td>And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.</td></tr><tr><td>7</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>7</td><td>7</td><td>And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.</td></tr><tr><td>8</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>8</td><td>8</td><td>And God called the firmament Heaven. And the evening and the morning were the second day.</td></tr><tr><td>9</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>9</td><td>9</td><td>And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.</td></tr><tr><td>10</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>10</td><td>10</td><td>And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.</td></tr><tr><td>11</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>11</td><td>11</td><td>And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.</td></tr><tr><td>12</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>12</td><td>12</td><td>And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.</td></tr><tr><td>13</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>13</td><td>13</td><td>And the evening and the morning were the third day.</td></tr><tr><td>14</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>14</td><td>14</td><td>And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:</td></tr><tr><td>15</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>15</td><td>15</td><td>And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.</td></tr><tr><td>16</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>16</td><td>16</td><td>And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.</td></tr><tr><td>17</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>17</td><td>17</td><td>And God set them in the firmament of the heaven to give light upon the earth,</td></tr><tr><td>18</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>18</td><td>18</td><td>And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.</td></tr><tr><td>19</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>19</td><td>19</td><td>And the evening and the morning were the fourth day.</td></tr><tr><td>20</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>20</td><td>20</td><td>And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.</td></tr><tr><td>21</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>21</td><td>21</td><td>And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.</td></tr><tr><td>22</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>22</td><td>22</td><td>And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.</td></tr><tr><td>23</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>23</td><td>1</td><td>And the evening and the morning were the fifth day.</td></tr><tr><td>24</td><td>1</td><td>1</td><td>gn</td><td>Genesis</td><td>1</td><td>1</td><td>24</td><td>2</td><td>And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.</td></tr></table></body>
    </html>
    Compare bible texts (and other tools):
    TheWheelofGod

  5. #5
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Didn't I say PHP? - You shown php above but there are no where near 120 lines of code.

    I won't ask again, so please show ALL the php code. NOT HTML.
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  6. #6
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tangoforce View Post
    Didn't I say PHP? - You shown php above but there are no where near 120 lines of code.

    I won't ask again, so please show ALL the php code. NOT HTML.
    I made some changes again in taking the th tag out because I'm not using it.
    I'll post the entire php page but here's the section I'm working on:
    PHP Code:
        //looking for the ths
        
    $file="saveddbtable/bible_small.htm";
        
    $contents_of_page file_get_contents($file);
        
    $dom = new DOMDocument();
        
    $dom->loadHTML($contents_of_page);
        
    // Initialize arrays
        
    $tdArray $array = array();

        
    // count the array for future comparison
        
    $count count($fields);
        
    /* Example:
        Array(
        [0] => Unit Type
        [1] => Availability
        [2] => Rates
        )
        */
        // Get all the Table Cells, but if it matches the same count as the Table Header array, create a new array row
        
    $td $dom->getElementsByTagName('td');
        
    $i 0;
        foreach( 
    $td as $td_field ){
            if(
    count($tdArray[$i]) != $count){
                
    $tdArray[$i][] = $td_field->nodeValue;
            }else{
                
    $i++;
                if(
    $i=20){
                    break;
                }
                
    $tdArray[$i][] = $td_field->nodeValue;
            }

        }
        
    $numRecordsPerPage 20;
        
    $offset $numRecordsPerPage * ($page 1);
        
    //$tdarr = implode("', '", array_slice($tdArray[0], 1));
        
        
    for($j $offset$j $offset $numRecordsPerPage$j++){
            
    // Add to insert statement
            
    $tdarr implode("', '"$tdArray[$j]);
            
    $sql "INSERT INTO ".$dbTable3." (".$fieldarr.") VALUES ('".$tdarr."')";
            echo 
    "<span style=\"color: green;\">".$sql."</span><br />\n";
            
    //mysql_query($sql) or die(mysql_error());
        
    }
    echo 
    '<pre>';
    //print_r(array_combine($fields, $tdArray));
    print_r($fields);
    print_r($tdArray);
    echo 
    '</pre>'
    Entire code:
    PHP Code:
    <?php 
    /*originally ins_bible_indb.php now create_bible.php March 23, 2011*/
    ob_start();
    header("Content-Type: text/html; charset=utf-8");
    error_reporting(E_ALL);
    ini_set('display_errors'true);
    set_time_limit(480); 
    include(
    "includefiles/colors.php");
    include(
    "dbconnection.php");
    /***************************/
    $type=isset($_GET["type"]) ? $_GET["type"] : "";
    $table=isset($_GET["table"]) ? $_GET["table"] : "";
    //$page=isset($_GET["page"]) ? $_GET["page"] : "";
    $page = isset($_GET["page"]) ? (int) $_GET["page"] : 1

    // Create database table
    if (mysql_query("CREATE DATABASE IF NOT EXISTS ".$dbname$con)){
        echo 
    "Database ".$dbname." created<br />\n";
    }else{
        echo 
    "Error creating database ".$dbname.": " mysql_error();
    }

    if(
    $type=="delete"){
    // Drop database table
        
    $delete_sql "DROP TABLE IF EXISTS ".$dbTable3;
        
    mysql_select_db($dbTable3);
        
    $retval mysql_query($delete_sql$con);
        if(! 
    $retval ){
            die(
    'Could not delete table: ' mysql_error());
        }
    }
    if(
    $type=="create"){
        
    //if($page==NULL){
            // Create table leave this out book_title_gr mediumtext,
            
    $sql "CREATE TABLE IF NOT EXISTS ".$dbTable3."(
                id MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
                book int(3),
                book_spoke int(3),
                recordType tinytext,
                book_title mediumtext,
                chapter int(3),
                chapter_spoke int(3),
                verse int(3),
                verse_spoke int(3),
                text_data longtext)"
    ;
            
                
    //collect the newly created fields to insert values within
                
    mysql_query($sql,$con) or die(mysql_error());
        
    //}
        
    echo "Table ".$dbTable3." created";
        
    $sql "SHOW FIELDS FROM ".$dbTable3;
        
    $result mysql_query($sql) or die(mysql_error());
        
    $fields = array();
        while (
    $show_column_names mysql_fetch_array($result)){
            if(
    $show_column_names['Field']!=="id"){
                
    $fields[]= $show_column_names['Field'];
            }
        }
        
    $fieldarr implode(", "$fields);
        
    //echo $fieldarr;
        
    $addPage $page+1;
        
    $goto $_SERVER['PHP_SELF']."?type=create&table=bible&page=".$addPage;
    }

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Page <?php echo $page;?> Inserting in the Bible Database Table</title>
    </head>

    <body>
    <?php
    /***********************************************************************************************************/
    if($type=="create"){
        
    //looking for the ths
        
    $file="saveddbtable/bible_small.htm";
        
    $contents_of_page file_get_contents($file);
        
    $dom = new DOMDocument();
        
    $dom->loadHTML($contents_of_page);
        
    // Initialize arrays
        
    $tdArray $array = array();

        
    // count the array for future comparison
        
    $count count($fields);
        
    /* Example:
        Array(
        [0] => Unit Type
        [1] => Availability
        [2] => Rates
        )
        */
        // Get all the Table Cells, but if it matches the same count as the Table Header array, create a new array row
        
    $td $dom->getElementsByTagName('td');
        
    $i 0;
        foreach( 
    $td as $td_field ){
            if(
    count($tdArray[$i]) != $count){
                
    $tdArray[$i][] = $td_field->nodeValue;
            }else{
                
    $i++;
                if(
    $i=20){
                    break;
                }
                
    $tdArray[$i][] = $td_field->nodeValue;
            }

        }
        
    $numRecordsPerPage 20;
        
    $offset $numRecordsPerPage * ($page 1);
        
    //$tdarr = implode("', '", array_slice($tdArray[0], 1));
        
        
    for($j $offset$j $offset $numRecordsPerPage$j++){
            
    // Add to insert statement
            
    $tdarr implode("', '"$tdArray[$j]);
            
    $sql "INSERT INTO ".$dbTable3." (".$fieldarr.") VALUES ('".$tdarr."')";
            echo 
    "<span style=\"color: green;\">".$sql."</span><br />\n";
            
    //mysql_query($sql) or die(mysql_error());
        
    }
    echo 
    '<pre>';
    //print_r(array_combine($fields, $tdArray));
    print_r($fields);
    print_r($tdArray);
    echo 
    '</pre>';

    /***********************************************************************************************************/
    ?>
    <h3>Taken From: <a href="<?php echo $file?>" target="_blank"><?php echo $file?></a></h3>
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?type=delete&table=bible">Delete Table</a>
    <a href="<?php echo $goto?>">next</a>
    <?php 
    }

    if(
    $type=="delete"){?>
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?type=create&table=bible&page=1">Create Table</a>
    <?php 
    }
    ?>
    <a href="<?php echo $_SERVER['PHP_SELF']; ?>?show=all<?php
    if($type=="create"){
        echo 
    "&type=create";
    }
    ?>">Show all</a>

    <?php
    ?>
    <a href="?page=<?php echo $page 1?>">Next page</a><?php
    /*if($type=="create"){
        //count($trInnerHTML[1])
        for($td=1; $td<5; $td++){
            preg_match_all($extract_td, $trInnerHTML[1][$td], $tdInnerHTML);
            $implode_record = implode(", ", $tdInnerHTML[1]);
            echo $implode_record;
        }
    }

    if($type=="create"){
        $num=round(count($trInnerHTML[1])/32);
        echo "<span style=\"color: orange;\">".$num."</span><br />\n";
        $start=$page*$num;
        $limit=$page*$num;
        $tds = array();
        echo "page = ".$page;
        for($getTds=$start; $getTds<$limit; $getTds++){//counting the trs
            if($getTds!==0){
                preg_match_all("#<td.*>(.+)</td#Ui", $trInnerHTML[1][$getTds], $tdInnerHTML);
                //print_r($tdInnerHTML[1]);
                echo "<span style=\"color: red;\">".count($tdInnerHTML[1])."</span>";
                //echo "<br />\n";
                for($splitTds=0; $splitTds<count($tdInnerHTML[1]); $splitTds++){
                    if($splitTds!==0){
                        $tds[] = addslashes($tdInnerHTML[1][$splitTds]);
                        echo "<span style=\"color: blue;\">".$tdInnerHTML[1][$splitTds]."</span><br />\n";
                    }
                    if($splitTds==count($tdInnerHTML[1])-1){
                        $tdarr = implode("', '", $tds);
                        $sql = "INSERT INTO ".$dbTable3." (".$fieldarr.") VALUES ('".$tdarr."')";
                        echo "<span style=\"color: green;\">".$sql."</span><br />\n";
                        mysql_query($sql) or die(mysql_error());
                        $tds = array();
                    }
                }
            }
        }
    }
    */
    mysql_close($con);
    if(
    $type=="create"){
    //then redirect them to the index
    $add=$page+1;
    echo 
    "Location: create_bible.php?type=create&table=bible&page=".$add;
    //header("Location: create_bible.php?type=create&table=bible&page=".$add);
    }
    ?>
    </body>
    </html>
    Compare bible texts (and other tools):
    TheWheelofGod

  7. #7
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe
    PHP Code:
    $file="saveddbtable/bible.htm";
    $contents_of_page file_get_contents($file); 
    doesn't work with
    PHP Code:
    $dom = new DOMDocument();
    $dom->loadHTML($contents_of_page); 
    Because when the source is in the same php file it works fine:
    PHP Code:
    <!DOCTYPE html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
    <?php
        $text 
    '
            <table>
                <tr>
                    <th>Unit Type</th>
                    <th>Availability</th>
                    <th>Rates</th>
                </tr>
                <tr>
                    <td>One Bedroom</td>
                    <td>Call for Availability</td>
                    <td>hello</td>
                </tr>
                <tr>
                    <td>One Living Room</td>
                    <td>Call not for Availability</td>
                    <td>hello</td>
                </tr>
                <tr>
                    <td>Two Bedrooms</td>
                    <td>Not Availabile</td>
                    <td>Good Bye</td>
                </tr>            
            </table>'
    ;
        echo 
    $text;
        
    $dom = new DOMDocument();
        
    $dom->loadHTML($text);
        
    // Initialize arrays
        
    $thArray $tdArray $array = array();
        
    // Get all Table Headers and throw them in an array
        
    $th $dom->getElementsByTagName('th');
        foreach ( 
    $th as $th ) {
            
    $thArray[] = $th->nodeValue;
        }
        
    // count the array for future comparison
        
    $count count($thArray);
        
    /* Example:
            Array
            (
                [0] => Unit Type
                [1] => Availability
                [2] => Rates
            )
        */
        // Get all the Table Cells, but if it matches the same count as the Table Header array, create a new array row
        
    $td $dom->getElementsByTagName('td');
        
    $i 0;
        foreach( 
    $td as $td ) {
            if(
    count($tdArray[$i]) != $count) {
                
    $tdArray[$i][] = $td->nodeValue;
            } else {
                
    $i++;
                
    $tdArray[$i][] = $td->nodeValue;
            }
        }
        echo 
    '<pre>';
            
    print_r(array_combine($thArray$tdArray));
        echo 
    '</pre>';
    ?>         
    </body>

    </html>
    Compare bible texts (and other tools):
    TheWheelofGod

  8. #8
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is something wrong with the $offset formula:
    PHP Code:
        $numRecordsPerPage 20;
        
    $offset $numRecordsPerPage * ($page 1); 
    So if $page=1 then $offset would result to 0.
    Compare bible texts (and other tools):
    TheWheelofGod

  9. #9
    SitePoint Enthusiast derokorian's Avatar
    Join Date
    Jan 2011
    Location
    Ohio
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually it should be zero on Page one, because on the first page you should be starting with the first result (aka no offset) however on page two, the first result should be the 21st record. Remember array ids go 0,1,2,3,... so the 21st record is actually of id 20.

    Hope that helps!

  10. #10
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by derokorian View Post
    Actually it should be zero on Page one, because on the first page you should be starting with the first result (aka no offset) however on page two, the first result should be the 21st record. Remember array ids go 0,1,2,3,... so the 21st record is actually of id 20.

    Hope that helps!
    Yes you're right. I realized that after I typed it.
    But I don't understand why the last $tdArray value is being left out. The following:
    PHP Code:
    echo '<pre>';
    //print_r(array_combine($fields, $tdArray));
    print_r($fields);
    print_r($tdArray[0]);
    echo 
    '</pre>'
    Shows:
    Array
    (
    [0] => book
    [1] => book_spoke
    [2] => recordType
    [3] => book_title
    [4] => chapter
    [5] => chapter_spoke
    [6] => verse
    [7] => verse_spoke
    [8] => text_data
    )
    Array
    (
    [0] => 1
    [1] => 1
    [2] => gn
    [3] => Genesis
    [4] => 1
    [5] => 1
    [6] => 1
    [7] => 1
    )
    Instead of:
    Array
    (
    [0] => book
    [1] => book_spoke
    [2] => recordType
    [3] => book_title
    [4] => chapter
    [5] => chapter_spoke
    [6] => verse
    [7] => verse_spoke
    [8] => text_data
    )
    Array
    (
    [0] => 1
    [1] => 1
    [2] => gn
    [3] => Genesis
    [4] => 1
    [5] => 1
    [6] => 1
    [7] => 1
    [8] => In the beginning God created the heaven and the earth.
    )
    Compare bible texts (and other tools):
    TheWheelofGod

  11. #11
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if($i=20){ 
    will always be true - it's assigning.
    PHP Code:
    if( 20 == $i ) { 
    A good habit to get which will avoid this type of error is to put the variable second. That way, if you put = instead of == PHP will error.
    - Robert


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
  •