Jump to content

gnrmatt

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by gnrmatt

  1. Hi, I have an XML Feed which is using ID's or Types. I need to select the specific node and convert it to a variable. Example XML Feed: <tour> <tourName>Amazon Riverboat Adventure</tourName> <dossierCode>PVIIA</dossierCode> <tripDetails> <tripDetail type="StartFinish">ex Lima</tripDetail> <tripDetail type="What's Included">Lots of stuff </tripDetail> </tripDetails> I have been extracting this data by using: <?php if(!$xml=simplexml_load_file('xmlfeed.xml')){ trigger_error('Error reading XML file',E_USER_ERROR); } foreach ($xml->tourName as $tourname) foreach ($xml->dossierCode as $agentcode) ?> However I am unsure how I can extract the "ex lima" from StartFinish as $startfinish. Can anyone help? Many thanks!
  2. Sorry - Resolved myself. For reference: <?php if(!$xml=simplexml_load_file('http://bookedy:bookED19@www.gapadventures.com/api/feeds/tours/PVIIA/')){ trigger_error('Error reading XML file',E_USER_ERROR); } foreach ($xml->tourName as $tourname){ echo $tourname; } ?>
  3. Hi, I'm trying to get to grips with basic PHP SimpleXml so please accept my apologise if i'm doing something blatently stupid here. I have an XML Feed as follows: <tour> <tourName>Amazon Riverboat Adventure</tourName> <dossierCode>PVIIA</dossierCode> <url>http://www.gapadventures.com/trips/amazon-riverboat-adventure/PVIIA/2011/</url> <tripDescription>Hop aboard a riverboat and experience the Amazon in style. The cuisine onboard is regional and provides a unique—and delicious—window into local culture. Led by an Amazon Reserve Naturalist guide, your cruise will include daily excursions by motorized skiff designed to reveal the exotic wildlife that calls the rainforest home—with any luck you’ll spot sloths, toucans or pink dolphins! And, with two full days for exploration in Pacaya Samiria Reserve, you'll have the chance to experience the jungle up close. Gain a rare glimpse of how life ‘on the river‘ is lived and experience the magic of the Amazon on this once-in-a-lifetime riverboat adventure.</tripDescription> <tripStyle>Classic</tripStyle> </tour> I want to get just the tour name from this so i have done: <?php // displays all the file nodes if(!$xml=simplexml_load_file('xmlfeed.xml')){ trigger_error('Error reading XML file',E_USER_ERROR); } // displays first user's name echo 'Displaying Tour Name... <br />'; echo $xml->$tour[0]->tourName; ?> However this fails to display the tourname for me. I'm sure it's something really stupid that i'm doing but any help is greatly appreciated! Many thanks! Matt
  4. Not to worry - Error has been resolved. For reference, I shouldn't have used while($row = mysql_fetch_array($result)) and instead used $row = mysql_fetch_assoc($result); Works a treat now.
  5. Yes - Connection above: if(isset($_GET['imgid'])) // if id is set then get the file with the id from database $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); I tried removing the content-disposition header on guidance from a different thread but that also didnt work.
  6. Hi, I am having an issue with displaying an image that is uploaded in a mysql database. The table format is ----------------------------------------------------------- | id | name | mime | size | data | ----------------------------------------------------------- | 1 | test | image/jpeg| 74857 | BLOB | The data has uploaded fine. I then have the following script on my 'displayimage.php?imgid=1' page... $id = $_GET['imgid']; $result = mysql_query("SELECT * FROM images WHERE id = '$id'"); while($row = mysql_fetch_array($result)) $size = $row['size']; $mime = $row['mime']; $name = $row['name']; { header("Content-length: $size"); header("Content-type: $mime"); header("Content-Disposition: attachment; filename=$name"); echo $row['data']; However everytime i try to open this page, Firefox or Internet Explorer just ask's me to try and download the file as a php file. Any ideas what is going wrong? Thanks! Matt
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.