Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/189349-what-am-i-doing-wrong/
Share on other sites

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

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.