www.webdeveloper.com
Results 1 to 7 of 7

Thread: [RESOLVED] I've Parsed & Parsed..Someone PLEASE Help Me..

  1. #1
    Join Date
    Sep 2008
    Posts
    260

    resolved [RESOLVED] I've Parsed & Parsed..Someone PLEASE Help Me..

    Hello.

    I've read all of the troubleshooting articles suggested at the top of this forum and troubleshooted my tail off.

    Can someone PLEASE help me find out why this isn't working.

    Please click on this link: http://www.sociallyaffluent.com/back_door2.php

    In the section highlighted in green, I'm making a call to an XML file and pulling information.

    The code to do this has been parsed over and over again and there aren't any errors in the code...yet I'm getting a "Port: 80 Internal Server Error"..

    Something is occurring with simplexml_load_file() and I can't figure what it is.

    If you want to look at the code, here it is:

    PHP Code:
    <?php

    function load_now(){

    require (
    "dimensions.php");

    $xml simplexml_load_file("http://www.volumestat.com/feed/");

       if (isset(
    $xml))
       {
            
           
    $count=0;
       
           foreach (
    $xml -> channel -> item as $item){
       
            
    $title trim($item -> title);
        
            if (isset(
    $title)){
        
                if ((
    preg_match("/(New)(\s?)(ATL)(\s?)(Music)/i"$title)) && ($count 5))
                {
        
                    
    $item_title substr($title0strpos($title'/[^A-Za-z0-9]/') - 1);
            
                    
    $item_artist substr($titlestrpos($title'/[^A-Za-z0-9]/') + 1);
            
            
                    if (
    strlen($item_artist) > 18)
                    {
            
                        
    $item_artist substr($item_artist018);
                
                    }
            
                    
    $item_link $item->link;
            
                      
    $item_description $item -> description;
            
                    if (
    strlen($item_description) > 54)
                    {
            
                        
    $item_description substr($item_description054);
            
                    }
            
            
                    foreach (
    $item -> enclosure as $img_tag){
            
                          
    $all_attributes $img_tag -> attributes();
                
                           foreach (
    $all_attributes as $a -> $b){
                
                            if (
    $a == "url")
                            {
                                
    $img_count=0;
            
                                if ((
    preg_match("/\.jpg/i"$b)) && ($img_count 1))
                                {
            
                                    
    $image_location=$b;
                                    
    $img_count++;
                                }
            
                            }
                        }
                    }
            
            
                    
    $target_array=$dimensions[$count];
            
                    for (
    $i=0$num_pos count($target_array); $i $num_pos$i++){
            
                        if (
    $i==0)
                        {
                
                            
    $int_width preg_replace("/[^0-9]/"''$target_array[$i][2]);
                            
    $int_height preg_replace("/[^0-9]/"''$target_array[$i][3]);
                    
                                  echo 
    '<div style="position:relative; left:'.$target_array[$i][0].' top:'.$target_array[$i][1].' width:'.$target_array[$i][2].' height:'.$target_array[$i][3].'">';
                
                            echo 
    '<a href="#" style="text-decoration:none; cursor:pointer;" onclick="viewMedia(\''.$item_link.'\');"><img src="'.$image_location.'" width="'.$int_width.'" height="'.$int_height.'" /></a>';
                    
                            echo 
    '</div>';
                    
                        }
                
                        if (
    $i==1)
                        {
                
                            echo 
    '<div style="position:relative; left:'.$target_array[$i][0].' top:'.$target_array[$i][1].' width:'.$target_array[$i][2].' height:'.$target_array[$i][3].' color:#ec9b0d;">';
                    
                            echo 
    '<a href="#" style="text-decoration:none; cursor:pointer; color:white;" onclick="viewMedia(\''.$item_link.'\');">'.$item_title.'</a>';
                    
                            echo 
    '</div>';
                    
                        }
                
                        if (
    $i==2)
                        {
                
                            echo 
    '<div style="position:relative; left:'.$target_array[$i][0].' top:'.$target_array[$i][1].' width:'.$target_array[$i][2].' height:'.$target_array[$i][3].' color:white;">';
                    
                            echo 
    '<a href="#" style="text-decoration:none; cursor:pointer; color:white;" onclick="viewMedia(\''.$item_link.'\');">'.$item_artist.'</a>';
                    
                            echo 
    '</div>';
                    
                        }
                
                        if (
    $i==3)
                        {
                
                            echo 
    '<div style="position:relative; left:'.$target_array[$i][0].' top:'.$target_array[$i][1].' width:'.$target_array[$i][2].' height:'.$target_array[$i][3].' color:white; font-size:9px;">'.$item_description.'</div>';
                    
                        }
                
                    } 
    //Close numerical for loop
            
                    
    $count++;
            
                } 
    // Close secondary "if" statement
            
            
    // Close secondary isset check
        
            
    else
            { echo 
    'The title variable was not set'; }
        
              }  
    //Close your main "for" loop
        
        
    // Close primary isset check
        
        
    else
        { echo 
    'The file did not load correctly'; }
     

    // Close function

    ?>

  2. #2
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    While I have not gone through and thoroughly analyzed your code, I did check the feed url http://www.volumestat.com/feed/ and if you view source on it (in Firefox, IE won't even open the feed) you will see at the end of it:
    Code:
    <b>Fatal error</b>:  Call to undefined function  get_the_post_thumbnail() in <b>/home/dvason/public_html/wp-content/plugins/mrss-with-thumbnail.php</b> on line <b>53</b><br />
    So the lack of correctly formed xml in the feed is likely a major problem...
    Last edited by astupidname; 07-25-2010 at 12:26 PM. Reason: browser clarification

  3. #3
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    So, actually you may want to change this:
    $xml = simplexml_load_file("http://www.volumestat.com/feed/");
    just slightly by suppressing error messages with the '@' symbol, change to this:
    $xml = @simplexml_load_file("http://www.volumestat.com/feed/");

  4. #4
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    Oh, and don't check for isset($xml), check for !($xml === false)

  5. #5
    Join Date
    Sep 2008
    Posts
    260
    Quote Originally Posted by astupidname View Post
    While I have not gone through and thoroughly analyzed your code, I did check the feed url http://www.volumestat.com/feed/ and if you view source on it (in Firefox, IE won't even open the feed) you will see at the end of it:
    Code:
    <b>Fatal error</b>:  Call to undefined function  get_the_post_thumbnail() in <b>/home/dvason/public_html/wp-content/plugins/mrss-with-thumbnail.php</b> on line <b>53</b><br />
    So the lack of correctly formed xml in the feed is likely a major problem...
    Okay...thanks for that. I found what was causing that and I deleted that file. Now, I'm just getting one error:

    Code:
    Cannot access empty property in /home/content/s/o/c/socialowner/html/load_volume.php on line 51
    Apparently may be an error in the actual code above...in this area

    PHP Code:
                    foreach ($item -> enclosure as $img_tag){
            
                          
    $all_attributes $img_tag -> attributes();
                
                            foreach (
    $all_attributes as $a => $b){
                
                            if (
    $a == "url")
                            {
                                
    $img_count=0;
            
                                if ((
    preg_match("/\.jpg/i"$b)) && ($img_count 1))
                                {
            
                                    
    $image_location=$b;
                                    
    $img_count++;
                                }
            
                            }
                        }
                    } 
    ..can you see something that I'm not calling right here?
    Last edited by ChuckB; 07-25-2010 at 01:07 PM.

  6. #6
    Join Date
    Sep 2008
    Posts
    260
    Quote Originally Posted by astupidname View Post
    While I have not gone through and thoroughly analyzed your code, I did check the feed url http://www.volumestat.com/feed/ and if you view source on it (in Firefox, IE won't even open the feed) you will see at the end of it:
    Code:
    <b>Fatal error</b>:  Call to undefined function  get_the_post_thumbnail() in <b>/home/dvason/public_html/wp-content/plugins/mrss-with-thumbnail.php</b> on line <b>53</b><br />
    So the lack of correctly formed xml in the feed is likely a major problem...
    Okay...thanks for that. I found what was causing that and I deleted that file. Now, I'm just getting one error:

    Code:
    Cannot access empty property in /home/content/s/o/c/socialowner/html/load_volume.php on line 51
    Apparently may be an error in the actual code above...in this area

    PHP Code:
                    foreach ($item -> enclosure as $img_tag){
            
                          
    $all_attributes $img_tag -> attributes();
                
                            foreach (
    $all_attributes as $a => $b){     //line 51   
                
                            
    if ($a == "url")
                            {
                                
    $img_count=0;
            
                                if ((
    preg_match("/\.jpg/i"$b)) && ($img_count 1))
                                {
            
                                    
    $image_location=$b;
                                    
    $img_count++;
                                }
            
                            }
                        }
                    } 
    ..can you see something that I'm not calling right here?

  7. #7
    Join Date
    Sep 2008
    Posts
    260
    Quote Originally Posted by astupidname View Post
    Oh, and don't check for isset($xml), check for !($xml === false)
    SOLVED!! Finally!....I mean...its not complete but if you look at the link I have the image and the text..

    the rest I can figure myself...formatting issues...

    Thanks for you assistance...if it wasn't for the suggestion about the "fatal error", I would spent days on this. Thanks man...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles