How do i fix this Fatal error: Uncaught exception 'Exception'

How do i fix this Fatal error: Uncaught exception 'Exception' it was working but i must have changed something now it comes up with

Fatal error: Uncaught exception 'Exception' with message 'SimpleXMLElement::__construct() expects exactly 1 parameter, 3 given' in /home/07009321/public_html/f1.php:23 Stack trace: #0 /home/07009321/public_html/f1.php(23): SimpleXMLElement->__construct('http://www.allc...', NULL, true) #1 {main} thrown in /home/07009321/public_html/f1.php on line 23
<!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>
    <title>test</title>
  </head>
 
  <body>
        <form name='frmTest' method='post' action='<?php echo $_SERVER['PHP_SELF'];?>'>
              <input type='text' name='txtSearch'/>
              <input type='submit' value='Search'/>
        </form>
        
    <?php
   
      if (isset($_POST["txtSearch"])) {
        $user_name = 'UserName';
        $secret_key = 'gfjuhchj';
        $search_phrase = $_POST["txtSearch"];
        $query_hash = md5($secret_key.$search_phrase);
        $xml_request_url = 'http://www.allcdcovers.com/api/search/'.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);
        $xml = new SimpleXMLElement($xml_request_url, null, true);
        
        if (isset($xml->err)) {
          echo $xml->err['msg'];
        } else {
        print "<table>";
          foreach ($xml as $title) {
           echo  "<tr><td><h3>'Title: '</h3>".$title->name."</td></tr><br />";
            echo "<tr><h3>'Category: ''</h3>".$title->category.': '.$title->subcategory."<br />";
            echo "<a href='Image: '><img src=".$title->image."/></a> <br /> ";     
            
    
            foreach ($title->covers->cover as $cover) {
             
                       echo "<h3>'Average rating:''</h3>".$cover->average_rating."<br />";
                                        }
          }
        }
      }
    ?>
  </body>
</html>

Open in new window

CiscoTavonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Minh Võ CôngCommented:
Can you describe the problem more clearly?
0
Carl TawnSystems and Integration DeveloperCommented:
Well, the error is complaining about the line:

     $xml = new SimpleXMLElement($xml_request_url, null, true);


The constructor only expects one parameter, but you are currently passing it 3.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CiscoTavonAuthor Commented:
I don't understand.  what should it say to get it to work?
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Carl TawnSystems and Integration DeveloperCommented:
What version of PHP are you using?
0
CiscoTavonAuthor Commented:
version 5.0.4

I followed the websites example code.

I'm trying to get album art
1.
      <?php
   2.
      $user_name = 'lennon_22';
   3.
      $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKTs';
   4.
      $search_phrase = 'beatles love';
   5.
      $query_hash = md5($secret_key.$search_phrase);
   6.
      $xml_request_url = 'http://www.allcdcovers.com/api/search/'.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);
   7.
      $xml = new SimpleXMLElement($xml_request_url, null, true);
   8.
      if (isset($xml->err)) {
   9.
        echo $xml->err['msg'];
  10.
      } else {
  11.
        foreach ($xml as $title) {
  12.
          echo 'Title: '.$title->name;
  13.
          echo 'Category: '.$title->category.': '.$title->subcategory;
  14.
          echo 'Image: '.$title->image;
  15.
          echo 'Image: '.$title->image;
  16.
          foreach ($title->covers->cover as $cover) {
  17.
            echo 'Cover type:'.$cover->type;
  18.
            echo 'Resolution:'.$cover->width.' '.$cover->height;
  19.
            echo 'Filesize:'.$cover->filesize;
  20.
            echo 'Upload date:'.$cover->uploaded_at;
  21.
            echo 'Average rating:'.$cover->average_rating;
  22.
            echo 'Download page:'.$cover->url;
  23.
            echo 'Thumbnail:'.$cover->thumbnail;
  24.
          }
  25.
        }
  26.
      }
  27.
      ?>

Open in new window

0
Carl TawnSystems and Integration DeveloperCommented:
Ah, that will be your problem then. Apparently SimpleXML requires PHP v5.1.2 or above.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.