Jump to content

beermaker74

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

beermaker74's Achievements

Member

Member (2/5)

0

Reputation

  1. i figuredit was something like that thanks
  2. if ($row_Recordset3['access'] !== ('var1' || 'var2')){do something} I need it to evaluate both vars and if one of them are not true its not evaluating both vars it works fine if i only use one ie if ($row_Recordset3['access'] !== 'var2'){do something} i have been up too many hours my brain is fried. can someone help please
  3. Ok going thru the xml dom for php 4 i came up with this that works for anybody else having the same problem $dom = domxml_open_mem($response, DOMXML_LOAD_PARSING, $errors); $noderoot = $dom->document_element(); $childnodes = $noderoot->child_nodes(); foreach($childnodes as $books) { if (($books->node_type() == 1) && ($books->node_name() == "entry")) { foreach ($books->child_nodes() as $theBook) { if (($theBook->node_type() == 1) && ($theBook->node_name() == "id")) { $id = $theBook->get_content(); } if (($theBook->node_type() == 1) && ($theBook->node_name() == "published")) { $published = $theBook->get_content(); } if (($theBook->node_type() == 1) && ($theBook->node_name() == "updated")) { $updated = $theBook->get_content(); } /* if (($theBook->node_type() == 1) && ($theBook->node_name() == "category")) { $category = $theBook->get_attribute('term'); }*/
  4. ok i am trying to parse some xml and it is becoming a royal pain in my arse. $base = 'http://google.com/base/feeds/snippets/-/'; $params = 'rental+%5blocation:@%22San+Francisco,CA%22%2b50mi%5d&max-results=3'; $url = $base . 'housing?bq=' . $params; $c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($c); curl_close($c); $dom = domxml_open_mem($response, DOMXML_LOAD_PARSING, $errors); foreach ($dom->documentElement->childNodes as $books) { if (($books->nodeType == 1) && ($books->nodeName == "entry")) { foreach ($books->childNodes as $theBook) { if (($theBook->nodeType == 1) && ($theBook->nodeName == "id")) { $id = $theBook->textContent; } It gives me an error in the foreach statement. It works fine on my local machine with php5. But not on my server with php4.4.4 here is the error Warning: Invalid argument supplied for foreach() before I had $doc = new DOMDocument(); $doc->load( 'books1.xml' ); to start the dom and I was getting errors. undefined function etc. dom needs a parameter. Once again worked fine on php5 but not on my server. So i changed that to $dom = domxml_open_mem($response, DOMXML_LOAD_PARSING, $errors); and that seemed to solve that problem but then the foreach problem came up. Somebody mentioned that the syntax I am using is for php 5. They recomended changing' foreach ($dom->documentElement->childNodes as $books) { to foreach ($dom->document_element->child_nodes as $books) { it is still giving me the same error my main goal in this is to display feeds from google base. So all i need to do is parse and display the feed in my own format. This code does exactly what I want in php 5. but im stuck woth 4.4.4
  5. ok i have a query to the google base and i am using curl to get the response. ok if i have dom load (something.xml) it works fine. but if i try and put the var from curl in there it breaks. says itis empty in my error. what do i need to do to load it in the dom so i can parse it? thanks $url ='http://google.com/base/feeds/snippets/-/housing?bq=rental+%5blocation:@%22athens,AL%22%2b50mi%5d&max-results=6'; $c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($c); curl_close($c); $dom = new DomDocument; $dom->load("$response"); foreach ($dom->documentElement->childNodes as $books) { if (($books->nodeType == 1) && ($books->nodeName == "entry")) { foreach ($books->childNodes as $theBook) { if (($theBook->nodeType == 1) && ($theBook->nodeName == "id")) { $id = $theBook->textContent; } if (($theBook->nodeType == 1) && ($theBook->nodeName == "published")) { $published = $theBook->textContent; }
  6. ok I am just trying to query google base and parse the result. here is the result from one item from google <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gm='http://base.google.com/ns-metadata/1.0' xmlns:g='http://base.google.com/ns/1.0' xmlns:batch='http://schemas.google.com/gdata/batch'> <id>http://www.google.com/base/feeds/snippets</id> <updated>2007-02-26T20:33:03.539Z</updated> <title type='text'>Items matching query: (rental [location:@"San Francisco,CA"+50mi]) [item type:housing]</title> <link rel='alternate' type='text/html' href='http://base.google.com'></link> <link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets'></link> <link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/batch'></link> <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/-/housing?start-index=1&max-results=1&bq=rental+%5Blocation%3A%40%22San+Francisco%2CCA%22%2B50mi%5D'></link> <link rel='next' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/-/housing?start-index=2&max-results=1&bq=rental+%5Blocation%3A%40%22San+Francisco%2CCA%22%2B50mi%5D'></link> <author> <name>Google Inc.</name> <email>base@google.com</email> </author> <generator version='1.0' uri='http://base.google.com'>GoogleBase</generator> <openSearch:totalResults>5812</openSearch:totalResults> <openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>1</openSearch:itemsPerPage> <entry> <id>http://www.google.com/base/feeds/snippets/2978077361409212904</id> <published>2007-02-26T12:10:23.000Z</published> <updated>2007-02-26T12:12:20.000Z</updated> <category scheme='http://base.google.com/categories/itemtypes' term='Housing'></category> <title type='text'>3 bedroom apartment rental in Berkeley California</title> <content type='html'>Elegant 3BR victorian unit available for short term rental 1/2 block to Bart transportation and close to the Berkeley Bowl (a great gourmet food market) and close to UC Berkeley.Unit was featured in Architectural Digest and has black walls wtih ...</content> <link rel='alternate' type='text/html' href='http://www.sublet.com/spider/supplydetails_adv.asp?SupplyId=337581&source=10228'></link> <link rel='self' type='application/atom+xml' href='http://www.google.com/base/feeds/snippets/2978077361409212904'></link> <author> <name>landlords@sublet.com</name> <email>landlords@sublet.com</email> </author> <g:image_link type='url'>http://base.google.com/base_image?q=http%3A%2F%2Fwww.sublet.com%2Faptimages%2F337581_1.jpg&dhm=53a74726&size=6</g:image_link> <g:city type='text'>Oakland</g:city><g:image_link type='url'>http://base.google.com/base_image?q=http%3A%2F%2Fwww.sublet.com%2Faptimages%2F337581_4.jpg&dhm=57e7adc0&size=6</g:image_link> <g:label type='text'>apartment for rent</g:label> <g:customer_id type='int'>1072962</g:customer_id> <g:bathrooms type='float'>1.0</g:bathrooms> <g:label type='text'>Oakland</g:label> <g:expiration_date type='dateTime'>2007-03-12T12:10:23.000Z</g:expiration_date> <g:label type='text'>vacation rental</g:label> <g:label type='text'>short term rental</g:label><g:item_type type='text'>Housing</g:item_type> <g:property_type type='text'>apartment</g:property_type> <g:label type='text'>temporary housing</g:label> <g:price type='floatUnit'>2500.0 usd</g:price> <g:label type='text'>California</g:label> <g:area type='text'>Berkeley</g:area> <g:item_language type='text'>EN</g:item_language> <g:image_link type='url'>http://base.google.com/base_image?q=http%3A%2F%2Fwww.sublet.com%2Faptimages%2F337581_3.jpg&dhm=5b620579&size=6</g:image_link> <g:location type='location'>California, 94703, USA</g:location> <g:label type='text'>vacation home</g:label> <g:label type='text'>holiday rental</g:label> <g:label type='text'>Berkeley</g:label> <g:area type='float'>1500.0</g:area> <g:bedrooms type='int'>3</g:bedrooms> <g:agent type='text'>Rinna</g:agent> <g:image_link type='url'>http://base.google.com/base_image?q=http%3A%2F%2Fwww.sublet.com%2Faptimages%2F337581_2.jpg&dhm=ffffffffac1031de&size=6</g:image_link> <g:listing_type type='text'>vacation rental</g:listing_type> <g:target_country type='text'>US</g:target_country> <g:id type='text'>337581</g:id> <g:image_link type='url'>http://base.google.com/base_image?q=http%3A%2F%2Fwww.sublet.com%2Faptimages%2F337581_5.jpg&dhm=ffffffffee4c399a&size=6</g:image_link> </entry> </feed> here is my code that I hacked from yahoo to parse it <?php $base = 'http://google.com/base/feeds/snippets/-/'; $params = 'rental+%5blocation:@%22San+Francisco,CA%22%2b50mi%5d&max-results=1'; $url = $base . 'housing?bq=' . $params; $c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($c); curl_close($c); $dom = domxml_open_mem($response, DOMXML_LOAD_PARSING, $errors); function xml_to_result($dom) { $root = $dom->document_element(); $res['totalResultsAvailable'] = $root->get_attribute('totalResultsAvailable'); $res['totalResultsReturned'] = $root->get_attribute('totalResultsReturned'); $res['firstResultPosition'] = $root->get_attribute('firstResultPosition'); $node = $root->first_child(); $i = 0; while($node) { switch($node->tagname) { case 'entry': $subnode = $node->first_child(); while($subnode) { $subnodes = $subnode->child_nodes(); if(!empty($subnodes)) { foreach($subnodes as $k=>$n) { if(empty($n->tagname)) { $res[$i][$subnode->tagname] = trim($n->get_content()); } else { $res[$i][$subnode->tagname][$n->tagname]=trim($n->get_content()); } } } $subnode = $subnode->next_sibling(); } break; default: $res[$node->tagname] = trim($node->get_content()); $i--; break; } $i++; $node = $node->next_sibling(); } return $res; } $res = xml_to_result($dom); echo '<pre>'; print_r($res); echo '</pre>'; ?> here is the result from that code print_r Array ( [totalResultsAvailable] => [totalResultsReturned] => [firstResultPosition] => [id] => http://www.google.com/base/feeds/snippets [updated] => 2007-02-26T20:42:47.146Z [title] => Items matching query: (rental [location:@"San Francisco,CA"+50mi]) [item type:housing] [link] => [author] => Google Inc.base@google.com [generator] => GoogleBase [totalResults] => 5805 [startIndex] => 1 [itemsPerPage] => 1 [0] => Array ( [id] => 337581 [published] => 2007-02-26T12:10:23.000Z [updated] => 2007-02-26T12:12:20.000Z [title] => 3 bedroom apartment rental in Berkeley California [content] => Elegant 3BR victorian unit available for short term rental 1/2 block to Bart transportation and close to the Berkeley Bowl (a great gourmet food market) and close to UC Berkeley.Unit was featured in Architectural Digest and has black walls wtih ... [author] => Array ( [name] => landlords@sublet.com [email] => landlords@sublet.com ) [city] => Oakland [item_language] => EN [image_link] => http://base.google.com/base_image?q=http%3A%2F%2Fwww.sublet.com%2Faptimages%2F337581_5.jpg&dhm=ffffffffee4c399a&size=6 [label] => apartment for rent [target_country] => US [agent] => Rinna [price] => 2500.0 usd [bathrooms] => 1.0 [area] => Berkeley [listing_type] => vacation rental [property_type] => apartment [expiration_date] => 2007-03-12T12:10:23.000Z [item_type] => Housing [bedrooms] => 3 [location] => California, 94703, USA [customer_id] => 1072962 ) ) the links are not coming through. they are blank. It seems that most other elements are there. The feed is an atom feed and the links seem to be encoded differently. I would really like to have access to the links. I am sure it is an easy fix. I am still a bit confused at all this xml parsing stuff. By the way I don't have php5 on my server so i cant use simplexml. thanks
  7. this might be a silly question but anyway here it goes. I want to have a link that goes to page 2 and displays data based on a post var without a form . I know i can do this very easily with get but I am always weary about attackers with that method so i always try and hide my info. So how can i pass a post var from a standard link? thanks
  8. thanks for the link. much easier than the custom database solution. I dont know what I would do without the great online communities here. damn i saw that they pop up an ad. or you can pay 10 a month for 10000 requests. Guess I will be using the maxmind solution. Has anybody here used it?
  9. I need to do some checks for someof my dynamic pages. What I need to do is go thru the complete table for one field and see if a value exists. the values are either y n or null. I only need to check for y. IS there a quick and dirty method to do this? Thanks for the help
  10. i have a page that has photos on it and i have a form that has a delete button. I have it directred to another page where the unlinking occursand the database field is updated. So I have a list menu that lists the photo numbers ie delete photo1 etc. This value is the name of the file that needs to be deleted. The problem i have is when they select photo1 to delete it sends that value to the next page but it does not know what field to delete it from. So what I want is when they click on photo1 it sends the name of the file and the named of the field. the field names are like photo1url photo2url etc. So if they select photo1 to delete i need it to send the name photo1.jpg plus photo1url for the field. Hope I am explaing it well enough. I have a hidden field hard coded right now to test it.works perfect so all i need it to dynamically assign this value. thanks
  11. check out http://www.maxmind.com/ they have a free version of their service that you can put in a mysql database to lookup the ip. the free service is updated once a month. I am about to do the same thing for my site so i can show info customized for their state
  12. is there a list of special chars that will mess up a linux system? I am creating xml with the files so I need to make sure everything is compliant. If I used str replace do I need to list every character? I was hoping there was some function that automatically did it. thanks
  13. is there a function that strips special characters. I already have it where it replaces spaces with underscores. I have been having problems with the & I am sure that there are a tremendous amount of special chars that will mess up my xml. So if there is something quick that can strip them please let me know thanks
  14. I have been developing this site and I have finally got around to doing the mod rewrite. i have a dynamic page www.myserver.com/listings.php?houseid=1. I have the rewrite now working with www.myserver.com/listings/1 I am more than happy with this address. The one thing I need to do is include the slash at the end of the url ie www.myserver.com/listings/1/ so that if they put this in the address bar that it directs them to www.myserver.com/listings/1. Since I am new at this rewriting I am not quite sure what is going on in the background. My issue is the links that I have on the page are all broken. But they work if I put absolute links. Is this what is required for it to work? Since it is only a few dynamic pages that I have to change it is no big deal but if i had 100 pages to change I would be a bit frustrated. So is there a way to deal with this. Maybe in the htaccess where my rewrite rules are? thanks
×
×
  • 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.