Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help With WordPress PHP Error!

    1) Project Details: (be as specific as possible): I had a friend write a small snippet of PHP code for one of my WordPress fly fishing websites. He is not around any more and I am getting an error on the page that uses the PHP code. here is the page where the error is: http://troutpic.com/stream-flows/

    Here is the warning that is generated at the top of the page: Warning: Invalid argument supplied for foreach() in /hermes/web10/b251/moo.rmtroutfitters/wp-content/plugins/php-execution-plugin/includes/class.php_execution.php(273) : eval()’d code on line 98

    I would pay whatever it takes for someone to fix this code for me.

    2) Payment Amount: Whatever is fair for the amount of work it will take to fix the error.

    3) Payment method/ details (Paypal, check? Timeline?): I will pay via PayPal and the timeline is negotiable.

    4) Additional Info (about project or potential bidders):

    <?php
    $dwr["Arkansas"] = array("ARKGRNCO", "ARKSALCO", "ARKWELCO");
    $dwr["Colorado"] = array("BLUNINCO");
    $ugs["Colorado"] = array("09050700", "09057500", "09058000", "09038500", "09064000", "09064600", "09073400", "09080400", "09081600", "09085000", "09085100");
    $ugs["Gunnison"] = array("09109000");
    $dwr["South Platte"] = array("BTABESCO", "BTBLESCO", "BTCANYCO", "PLAANTCO", "PLABAICO", "PLACHECO", "PLAGEOCO", "PLAHARCO", "PLASTRCO");
    $ugs["South Platte"] = array("06716500", "06719505");
    $ugs["Yampa"] = array("09237500", "09239500");

    $stations = array();
    foreach ($ugs as $v) {
    $stations = array_merge($stations, $v);
    }
    $sites = implode(",", $stations);
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://waterservices.usgs.gov/nwis/iv?sites=" . $sites . "&parameterCd=00060");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    $str = str_replace("ns1:", "ns1", $result);
    $xml = simplexml_load_string($str);
    foreach ($xml->ns1timeSeries as $station) {
    $stream = "";
    foreach ($ugs as $k => $v) {
    if (in_array((string) $station->ns1sourceInfo->ns1siteCode, $v)) {
    $stream = $k;
    }
    }
    if (!$stream) {
    continue;
    }
    $attributes = $station->ns1values->ns1value->attributes();
    $sdate = (string) $attributes["dateTime"];
    $date = new DateTime($sdate);
    $sdate = date_format($date, 'n/j/Y g:i:s A');
    $streams[$stream][(string) $station->ns1sourceInfo->ns1siteCode] = array("name" => (string) $station->ns1sourceInfo->ns1siteName, "field" => "", "time" => $sdate, "value" => str_replace("-999999", "N/A", (string) $station->ns1values->ns1value));
    }
    $xml_data = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <GetSMSTransmittingStations xmlns="http://www.dwr.state.co.us/">
    <Div>0</Div>
    <WD>0</WD>
    <Abbrev></Abbrev>
    </GetSMSTransmittingStations>
    </soap:Body>
    </soap:Envelope>';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_URL, "http://www.dwr.state.co.us/SMS_WebService/ColoradoWaterSMS.asmx");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "Content-Length: " . strlen($xml_data), 'SOAPAction: "http://www.dwr.state.co.us/GetSMSTransmittingStations"'));
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
    curl_setopt($ch, CURLOPT_POST, 1);
    $result = curl_exec($ch);
    preg_match('#<GetSMSTransmittingStationsResult>(.*)</GetSMSTransmittingStationsResult>#', $result, $matches);
    $xml = simplexml_load_string($matches[0]);

    foreach ($xml->Station as $station) {
    $names[(string) $station->abbrev] = (string) $station->stationName;
    }
    ksort($names);
    $xml_data = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <GetSMSTransmittingStationVariables xmlns="http://www.dwr.state.co.us/">
    <Div>0</Div>
    <WD>0</WD>
    <Abbrev></Abbrev>
    </GetSMSTransmittingStationVariables>
    </soap:Body>
    </soap:Envelope>';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_URL, "http://www.dwr.state.co.us/SMS_WebService/ColoradoWaterSMS.asmx");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "Content-Length: " . strlen($xml_data), 'SOAPAction: "http://www.dwr.state.co.us/GetSMSTransmittingStationVariables"'));
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
    curl_setopt($ch, CURLOPT_POST, 1);
    $result = curl_exec($ch);
    preg_match('#<GetSMSTransmittingStationVariablesResult>(.*)</GetSMSTransmittingStationVariablesResult>#', $result, $matches);
    $xml = simplexml_load_string($matches[0]);
    foreach ($xml->StationVariables as $variable) {
    $stations[(string) $variable->abbrev][] = (string) $variable->variable;
    }
    foreach ($stations as $abbrev => $variables) {
    $stream = "";
    foreach ($dwr as $k => $v) {
    if (in_array($abbrev, $v)) {
    $stream = $k;
    }
    }
    if (!$stream) {
    continue;
    }
    foreach ($variables as $variable) {
    if (substr($variable, 0, 7) != "DISCHRG") {
    continue;
    }
    $xml_data = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <GetSMSProvisionalData xmlns="http://www.dwr.state.co.us/">
    <Abbrev>' . $abbrev . '</Abbrev>
    <Variable>' . $variable . '</Variable>
    <StartDate>' . date('Y-m-d H:i', strtotime('-20 hours')) . '</StartDate>
    <EndDate>' . date('Y-m-d H:i') . '</EndDate>
    <Aggregation></Aggregation>
    </GetSMSProvisionalData>
    </soap:Body>
    </soap:Envelope>';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_URL, "http://www.dwr.state.co.us/SMS_WebService/ColoradoWaterSMS.asmx");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml", "Content-Length: " . strlen($xml_data), 'SOAPAction: "http://www.dwr.state.co.us/GetSMSProvisionalData"'));
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
    curl_setopt($ch, CURLOPT_POST, 1);
    $result = curl_exec($ch);
    preg_match('#<GetSMSProvisionalDataResult>(.*)</GetSMSProvisionalDataResult>#', $result, $matches);
    $xml = "";
    @$xml = simplexml_load_string($matches[0]);
    if ($xml) {
    foreach ($xml->StreamflowTransmission as $variable) {
    $streams[$stream][(string) $variable->abbrev] = array("name" => $names[(string) $variable->abbrev], "field" => (string) $variable->variable, "time" => (string) $variable->transDateTime, "value" => (string) $variable->amount);
    }
    }
    }
    }
    ksort($streams);
    ?>
    <div id="accordion">
    <?php
    foreach ($streams as $k => $v) {
    ?>
    <h3><?php echo $k; ?></h3>
    <div>
    <table>
    <tbody>
    <tr>
    <th class="thsize1">Stream Name</th>
    <th class="thsize2">Station ID</th>
    <th class="thsize2">Last Updated</th>
    <th class="thsize3">CFS</th>
    </tr>
    <?php
    ksort($v);
    foreach ($v as $station => $variables) {
    if ($variables["field"]) {
    echo "<tr><td>" . $variables["name"] . "</td><td><a href='http://www.dwr.state.co.us/SurfaceWater/data/detail_graph.aspx?ID=" . $station . "&amp;MTYPE=" . $variables["field"] . "' target='_blank'>" . $station . "</a></td><td>" . $variables["time"] . "</td><td style='text-align: right;'>" . $variables["value"] . "</td></tr>";
    } else {
    echo "<tr><td>" . $variables["name"] . "</td><td>" . $station . "</td><td>" . $variables["time"] . "</td><td style='text-align: right;'>" . $variables["value"] . "</td></tr>";
    }
    }
    ?></tbody>
    </table>
    </div>
    <?php
    }
    ?>
    </div>
    Last edited by troutpic; 03-24-2011 at 05:54 AM. Reason: adding code for help...

  • #2
    New Coder Preeya's Avatar
    Join Date
    Sep 2010
    Location
    Delhi-NCR (India)
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    I would love to help you please send me the codes in am email. then we will discuss further. I will do this in an hour only.

    please feel free to contact me on: priya.bizarredesigns@gmail.com

    Looking forward to hear from you.
    Last edited by Preeya; 03-24-2011 at 08:32 AM.
    Get a Simple 5 pages website in only $99
    Contact on skype "ashishsaxena.net"


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •