underv3 Posted August 15, 2008 Share Posted August 15, 2008 How would I put a variable and a string together. For example if I had $test and I wanted to add "random" after the variable how would I go about that? Real life example would be in a search engine when making a request and I want to add a certain keyword that will always come after what is searched. Thanks Link to comment Share on other sites More sharing options...
pocobueno1388 Posted August 15, 2008 Share Posted August 15, 2008 <?php $text = "Blah blah blah"; //add something to end $text .= " something else"; echo $text; ?> Link to comment Share on other sites More sharing options...
underv3 Posted August 15, 2008 Author Share Posted August 15, 2008 How can I put a space before the addition? Link to comment Share on other sites More sharing options...
underv3 Posted August 15, 2008 Author Share Posted August 15, 2008 Oh.. I just saw the space there Link to comment Share on other sites More sharing options...
pocobueno1388 Posted August 15, 2008 Share Posted August 15, 2008 So does that answer all your questions? Link to comment Share on other sites More sharing options...
underv3 Posted August 15, 2008 Author Share Posted August 15, 2008 Yes, thanks, but there is my other post http://www.phpfreaks.com/forums/index.php/topic,212118.0.html This issue is still troubling me, if you could help out that would be great. Thanks I am working on a program that can get bio's for music artists and i came across this http://www.davidcraddock.net/2008/06/18/scraping-artists-bios-off-of-wikipedia/ It seems like a good start but when i attempted to run it I got some errors leading me to believe that the yahoo API implementation was outdated. Working from this i then added the "echo grabwiki(Rihanna);" as a test just to see if it would work. It looks as though everything works until it gets to "$b = $s->xpath("//p:abstract [xml:lang='en']");". I have no idea what to do with this line of code. I've been playing around with the code and searching google but I can't seem to make it work. The errors: Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: Undefined namespace prefix in /home/jamesad/public_html/searchbio.php on line 16 Warning: SimpleXMLElement::xpath() [simplexmlelement.xpath]: xmlXPathEval: evaluation failed in /home/jamesad/public_html/searchbio.php on line 16 <?php function grabwiki($band){ $band = urlencode($band); $yahoourl = 'http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=%22$band%22%20music&site=wikipedia.org'; $x = file_get_contents($yahoourl); $s = new SimpleXMLElement($x); $ar = split('/',$s->Result->Url); if($ar[2] == 'en.wikipedia.org'){ $wikikey = $ar[4]; // more than likely to be the wikipedia page }else{ return ""; // nothing on wikipediea } $url = "http://dbpedia.org/data/$wikikey"; $x = file_get_contents($url); $s = new SimpleXMLElement($x); $b = $s->xpath("//p:abstract[xml:lang='en']"); return $b[0]; } // if ($band == false) { // die("No Information Available"); //} echo grabwiki(Rihanna); ?> If someone has any ideas I would be open to any suggestions. Thanks! Link to comment Share on other sites More sharing options...
Barand Posted August 16, 2008 Share Posted August 16, 2008 This just became a double post. Locking. Link to comment Share on other sites More sharing options...
Recommended Posts