zimsabre Posted January 21, 2010 Share Posted January 21, 2010 here is my script.. saved as bluedragonscale.php <?php //Just change the item name inside the "" to change what item to price check!!! $item = strtolower("blue dragon scale"); $itemfixed = str_replace( " ", "+", $item ); if(!function_exists('function_name')) { function( function_name() { function parseString( $start, $end, $string ) { $before = explode( $start, $string ); $return = explode( $end, $before[1] ); return $return[0]; } $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, 'http://services.runescape.com/m=itemdb_rs/results.ws?query='.$item ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); $contents = strtolower( curl_exec ( $ch ) ); curl_close ( $ch ); $price = parseString( "$item</a></td>\n<td>", "</td>", $contents ); echo "".$price."Gp"; } } ?> and im using this to pull it up on a web page <?php include("../prices/bluedragonscale.php"); ?> my problem is if i have more than one "include" on a web page i end up with an error? like this <?php include("../prices/bluedragonscale.php"); ?> <?php include("../prices/anotheritem.php"); ?> look here at the error i get..[link]http://moneymethods.110mb.com/p2pmethods/summerpies.php[/link] Thanks Zimsabre Quote Link to comment https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/ Share on other sites More sharing options...
wildteen88 Posted January 21, 2010 Share Posted January 21, 2010 Move this block of code function parseString( $start, $end, $string ) { $before = explode( $start, $string ); $return = explode( $end, $before[1] ); return $return[0]; } Outside of your function_name() function declaration Quote Link to comment https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/#findComment-999531 Share on other sites More sharing options...
zimsabre Posted January 21, 2010 Author Share Posted January 21, 2010 what would the new script look like? Quote Link to comment https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/#findComment-999535 Share on other sites More sharing options...
zimsabre Posted January 22, 2010 Author Share Posted January 22, 2010 anyone? sorry im a bit slow when it comes to php, i have been learning html and decided to add in some php but i have come unstuck with this one. Quote Link to comment https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/#findComment-999784 Share on other sites More sharing options...
rajeevbharti Posted January 22, 2010 Share Posted January 22, 2010 code looks good u try <?php include("../prices/bluedragonscale.php"); include("../prices/anotheritem.php"); ?> instead of <?php include("../prices/bluedragonscale.php"); ?> <?php include("../prices/anotheritem.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/#findComment-999786 Share on other sites More sharing options...
zimsabre Posted January 22, 2010 Author Share Posted January 22, 2010 hey thanks, i have tryed that and i still get this error message, the first one works and all following includes i get an error? Fatal error: Cannot redeclare parsestring() (previously declared in /www/110mb.com/m/o/n/e/y/m/e/t/moneymethods/htdocs/prices/bluedragonscale.php:6) in /www/110mb.com/m/o/n/e/y/m/e/t/moneymethods/htdocs/prices/bluedragonscale.php on line 11 Quote Link to comment https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/#findComment-1000125 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.