Jump to content

What am i doing wrong?


zimsabre

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

Archived

This topic is now archived and is closed to further replies.

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