River page error

Im getting an error on my river page, hopefully someone will have a fix.

Warning: number_format() expects parameter 1 to be double, string given in /virtual/users/e16108-17165/web/wxriverdetail.php on line 225

Line 225… if(number_format($ObsStage,2)<number_format($action,2) and $action!=“”) { ?>



Mine is broken as well. Is your site hosted by E-Rice? My guess is they changed a config on their servers that broke something in the script…fopen and curl are the errors I’m seeing when I run the fetch script.

Hi Dan,

Just for your info, the wxriverpage is working fine for me. I’m not on e-rice.


Ok, fixed mine…found one of the gauges in my fetch file was bad, once I removed it the page started working. I’ll take another look at your issue and see if I spot anything else…nothing jumps out at me. I googled that error and it sounds like either a null value is being returned, or a non-numeric. Have you tried deleting the contents of the cache file and doing another fetch?

I am on erice.

I’ll try deleting the cache contents and see what happens.

I found the river that caused my issue by looking at the map showing all the local rivers. All the stations were green except one, it was gray. Apparently that sensor is bad and/or not reporting data…when I clicked on the icon it said the data was over 150 hours old. So I removed that one river from the config file and now everything is working again. Just wanted to share what I found with my setup in case anyone else experiences a similar problem.

Mark, please attach the code. I think it’s a simple fix but I don’t want to break something else.

OK… I’ll attach the whole script after work today.

The river detail page is attached. There the same errors on lines 225 and 173

river-detail.txt (20.1 KB)

Sorry Mark, I’ll have to defer to someone else who is more familiar with that code :frowning:

Not a lot of help, but maybe a clue to get you started?
When I view your wxriverdetail.php page directly by itself, I’m seeing this error code: id=‘’ is not defined.
Could be an incorrect path setting somewhere, or the url address has changed?

That’s cool… Thanks for trying.

Where are you seeing id=‘’ is not defined.
Cause Im not seeing that.

Edit: I see it now… that’s interesting.

There is id=‘’ at the start of the wxriverdetail.php page:

[color=blue]$riverid=$_GET[‘id’]; // Get River ID from address bar
if(!isset($RiverGauge[$riverid])) { // Check if gauge is in list Thanks to Ken True
echo “

id=‘$riverid’ is not formatted correctly.

$xmlFileData = “./River/river-$riverid.txt”;
$xmlData = simplexml_load_file($xmlFileData); // Parse the XML data

$Path = (string)$xmlData->observed;
	echo "<p>The xml file for this river is invalid</p>\n";

Its odd cause all of the rivers I have selected are updating fine, just with the error I posted above.

What does the code for your wxriverdetails.php show for this? (note that I’m using a separate folder f called “River”, so you may want to ignore that in my code.)

$xmlFileData = “./River/river-$riverid.txt”;

O.K…never mind. I thought we might be on to something. A direct call to my own wxriverdetail.php does the same thing, ie id=‘’ Not Defined. But my pages all work correctly, so must not have anything to do with your problem. Sorry to send you on a goose chase. You might want to ask Ken about this?

Not a problem. Thanks for trying.

My source file shows:

<tr align="center">
        <td 		bgcolor="#04B404">
62.25 ft</td>
        <td >0.51 kcfs</td>

Your page shows:

<tr align="center">

<b>Warning</b>:  number_format() expects parameter 1 to be double, string given in <b>/virtual/users/e16108-17165/web/wxriverdetail.php</b> on line <b>225</b>

3.379 kcfs</td>
        <td 		bgcolor="#04B404">
6.4 ft</td>

You have a break in the code, not sure where it’s coming from but might be a clue…

I think that’s because of the php error, but can you attach your code and maybe a comparison will tell us something.

Here’s my php page and config file…

RiverDetail.zip (5.53 KB)

Thanks Dan :slight_smile:

Mark, I suggest you switch to using Dan’s Version: 3.11F code instead of your 2.15. If you compare similar lines between the two you can see that 3.11F has (double) added which should eliminate the error - which was because it was looking for a double, not a string, not sure how it worked before :? (There are too many lines to change to fix 2.15.)

}elseif(number_format($ObsStage,2)<number_format($flood,2) and $flood!="" and $action =="") {
		echo "Normal";
}elseif(number_format((double)$ObsStage,2)<number_format((double)$flood,2) and $flood!="" and $action =="") {
				echo "Normal";