Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 26th, 2018, 11:28 PM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
Default why json_encode( all of a sudden stopped encoding the php arrays

I'm stuck on why json_encode( all of a sudden stopped encoding the php arrays int JavaScript arrays. It shows them empty.

PHP Code:
    $js_data = Array();

    for($i=0;$i<count($newStrongsResult);$i++){
        
        $searchStrongs = "SELECT * FROM ".$dbTable13." WHERE strongs = '".$newStrongsResult[$i]."' AND ";
        $searchStrongs .= "(";
        $searchStrongs .= " (book = '".$getB1."' AND chapter = '".$getC1."') OR ";
        $searchStrongs .= " (book = '".$getB2."' AND chapter = '".$getC2."') ";
        $searchStrongs .= ")";
        $searchStrongsResult = $conn->query($searchStrongs);
        
        while($row = $searchStrongsResult->fetch(PDO::FETCH_ASSOC)) {
            $searchStrongs_id[$i][] = $row['id'];
            $searchStrongs_book[$i][] = $row['book'];        
            $searchStrongs_bookTitle[$i][] = $row['book_title'];
            $searchStrongs_recordType[$i][] = $row['recordType'];        
            $searchStrongs_chapter[$i][] = $row['chapter'];
            $searchStrongs_verse[$i][] = $row['verse'];
            $searchStrongs_bookSpoke[$i][] = $row['book_spoke']; 
            $searchStrongs_chapterSpoke[$i][] = $row['chapter_spoke']; 
            $searchStrongs_verseSpoke[$i][] = $row['verse_spoke'];
            $searchStrongs_textData[$i][] = $row['text_data'];        
            $searchStrongs_strongs[$i][] = $row['strongs'];
            $searchStrongs_transliteration[$i][] = $row['transliteration'];
            $searchStrongs_etymology[$i][] = $row['etymology'];
            $searchStrongs_etymStrongs[$i][] = $row['etym_strongs'];
            $searchStrongs_etymDesc[$i][] = lcfirst($row['etym_desc']);
            $searchStrongs_hebWord[$i][] = hebrevc($row['heb_word']);
            $searchStrongs_added[$i][] = $row['added'];
            $searchStrongs_also[$i][] = $row['also'];
        }
        
        $joinedTextData = "('".implode("', \n'", $searchStrongs_textData[$i])."')\n\n";
        
        $joinedTransliteration = "('".implode("', \n'", $searchStrongs_transliteration[$i])."')\n\n";
        $joinedHebrewword = "('".implode("', \n'", $searchStrongs_hebWord[$i])."')\n\n";
        $joinedStrongs_etymDesc = "('".implode("', '", $searchStrongs_etymDesc[$i])."')\n\n";
        
        $joined_Transliteration_Hebrewword_Strongs_etymDesc = Array();
        
        for($j=0;$j<count($searchStrongs_transliteration);$j++){
            $joined_Transliteration_Hebrewword_Strongs_etymDesc = Array(    
                $searchStrongs_transliteration[$j][0],
                $searchStrongs_hebWord[$j][0],
                $searchStrongs_etymDesc[$j][0]);
        }

        $js_data[] = Array($i, $newStrongsResult[$i], $joinedTextData, count($searchStrongs_textData[$i]), $joined_Transliteration_Hebrewword_Strongs_etymDesc, $searchStrongs_added[0], $searchStrongs_also[0], $colors[$i]);
    }

/**************************************/
<?php /*?>
        $id[] = $row['id'];
        $book[] = $row['book'];        
        $bookTitle[] = $row['book_title'];
        $recordType[] = $row['recordType'];        
        $chapter[] = $row['chapter'];
        $verse[] = $row['verse'];
        $bookSpoke[] = $row['book_spoke']; 
        $chapterSpoke[] = $row['chapter_spoke']; 
        $verseSpoke[] = $row['verse_spoke'];
        $textData[] = $row['text_data'];        
        $strongs[] = $row['strongs'];
        $transliteration[] = $row['transliteration'];
        $etymology[] = $row['etymology'];
        $etymStrongs[] = $row['etym_strongs'];
        $etymDesc[] = lcfirst($row['etym_desc']);
        $hebWord[] = hebrevc($row['heb_word']);
        $added[] = $row['added'];
        $also[] = $row['also'];
<?php */
?>    

var js_text1 = <?php echo json_encode($js_text1); ?>;

var js_text2 = <?php echo json_encode($js_text2); ?>;

<?php /*?> 
    0    $i, 
    1    $newStrongsResult[$i], 
    2    $joinedTextData, 
    3    count($searchStrongs_textData[$i]), 
    4    $joined_Transliteration_Hebrewword_Strongs_etymDesc, 
    5    $searchStrongs_added[0], 
    6    $searchStrongs_also[0], 
    7    $colors[$i]
<?php */
?>

var js_data = <?php echo json_encode($js_data); ?>;

var js_newStrongsResult = [<?php echo '"'.implode('","'$newStrongsResult).'"' ?>]; //$php_array
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
php stopped handling errors gkman BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 4 February 19th, 2012 01:27 PM
PHP array_push() for associative arrays mcmahonc Beginning PHP 1 January 9th, 2010 01:13 PM
HOW TO USE STRINGS,ARRAYS AND VARIABLES IN PHP jhan316 Beginning PHP 1 July 25th, 2006 08:17 PM
php compare 2 arrays lucian PHP How-To 0 February 23rd, 2006 12:53 PM
Mysql,PHP and arrays swedge MySQL 1 February 15th, 2006 07:55 AM



All times are GMT -4. The time now is 08:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.