troubleshooting Question

Debug PHP Script

Avatar of Bob Conklin
Bob ConklinFlag for United States of America asked on
Web Languages and StandardsPHP
23 Comments1 Solution210 ViewsLast Modified:
Greetings...
I have a PHP script file that was written by some one else who no longer is around to ask how to fix the issue. I do not have a lot of experience, practical, or otherwise in decoding this type of scripting.

The basic process as I understand it, is to take data from a generated tide table, figure out the time to the next tide, either high or low, and display that on a web page with an appropriate graphic. The script has not worked correctly for me. Either it fails totally, or instead of accurately telling the time to the next tide, it will tell the time to the next tide 24 hours away.

I do know that the script does work on other websites, but I can't seem to be able to troubleshoot it in my instance.
Here is the code....(no private data is in this code snip)
the Variable $S3C2 is set in the configuration page, the value of 2 tells the displaying page to use the tide script.

<?php if (($S3C2 == 2) or ($S3C2 == 5)) {  //  Show Tide, Lightning will over-ride ?>
                        <?php
                        $tide = tide_data(0);
                        $tide1 = tide_data(1);
                        //print_r($tide);
                        //print_r($tide1);
                        $next_tides = array();
                        if (is_array($next_t1 = next_tide_info($tide[1], 0)))
                            $next_tides = $next_tides + $next_t1;
                        if (is_array($next_t2 = next_tide_info($tide[2], 0)))
                            $next_tides = $next_tides + $next_t2;
                        if (is_array($next_t3 = next_tide_info($tide[3], 0)))
                            $next_tides = $next_tides + $next_t3;
                        if (is_array($next_t4 = next_tide_info($tide[4], 0)))
                            $next_tides = $next_tides + $next_t4;
                        if (is_array($next_t5 = next_tide_info($tide[5], 0)))
                            $next_tides = $next_tides + $next_t5;
                        if (is_array($next_t1 = next_tide_info($tide1[1], 1)))
                            $next_tides = $next_tides + $next_t1;
                        if (is_array($next_t2 = next_tide_info($tide1[2], 1)))
                            $next_tides = $next_tides + $next_t2;
                        if (is_array($next_t3 = next_tide_info($tide1[3], 1)))
                            $next_tides = $next_tides + $next_t3;
                        if (is_array($next_t4 = next_tide_info($tide1[4], 1)))
                            $next_tides = $next_tides + $next_t4;
                        if (is_array($next_t5 = next_tide_info($tide1[5], 1)))
                            $next_tides = $next_tides + $next_t5;
                        // figure out wich tide is the next one
                        ksort($next_tides);
                        //print_r ($next_tides);
                        //print '<br>';
                        foreach ($next_tides as $k => $v) {
                            if ($k >= 0) {
                                $mins_to_next_tide = $k;
                                $tide_type = $v;
                                break;
                            }
                            }
                        echo "<tr><td style='text-align:center;'>";
                        $next_tide_time = date('h:i A T', strtotime("+$mins_to_next_tide minutes"));
                        echo "<p>" . time_till_tide($mins_to_next_tide * 60) . " to " .
                        $tide_type . " tide at<br />" . $next_tide_time . "</p>";
                        $mins_to_next_tide_rounded = round_tide_time($mins_to_next_tide);
                        $tide_image = select_tide_image($mins_to_next_tide_rounded, $tide_type);
                        echo "<img src=\"tides/$tide_image\" width=\"150\" alt=\"\"/><br />";
                        echo "</td></tr>";
                        //echo $nexttidequarter;
                        ?>
<?php } // end $useTide ----------------------------------------- ?>              

I am not sure what else in the way of information is needed to help debug this...
Thank you
-Bob
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 23 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 23 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros