Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Posts posted by hitman6003

  1. hitman6003, I'm not positive, but I think that you may still have floating point inaccuracies with that....

     

    I just retried, and discovered that this is the most decimal places it will recognize before rounding:

     

    $a['small_float'] = (float) 4.000000000000001;

     

    Prior to that it works.

     

    It may work with more decimal places on a 64 bit system.

  2. Perhaps some examples will help?

     

    <?php
    
    $a['int'] =  (int) 4;
    $a['float_but_int'] = (float) 4.00;
    $a['normal_float'] = (float) 4.1;
    $a['small_float'] = (float) 4.0000000000001;
    $a['negative_float'] = (float) -5.00004;
    
    foreach ($a as $name => $value) {
    echo $name . "'s value is: " . $value . "\n";
    
    if (is_int($value)) {
    	echo $name . " is an integer.\n";
    }
    
    if (is_float($value)) {
    	echo $name . " is a float.\n";
    }
    
    if ($value - floor($value) == 0) {
    	echo $name . " was determined to be a whole number (integer).\n";
    }
    
    if ($value - floor($value) != 0) {
    	echo $name . " was determined not to be a whole number (float).\n";
    }
    
    echo str_repeat("-", 25) . "\n";
    }

     

    By subtracting floor($value) from $value and seeing if there is a remainder, you can determine if it's a whole number.

  3. InnoDB employs MultiVersioning Concurrency Controls...which is a fancy way of saying that when you initiate a transaction (and all queries are transactions, you don't have to issue "START TRANSACTION / COMMIT" because autocommit is on by default) you will see the database in that state at all times until the transaction is committed.  So, if your transaction is a "COUNT" query it will return the number of rows present in the table at the start of the transaction (this behavior can be changed via the SQL mode).

     

    Additionally, while MyISAM keeps track of the current number of rows at any given time (and uses that number if the situations provided by the manual above), in any other situation it has the very real potential of locking the entire table while it does a row count.  Not a big deal with 100 rows in a table, but with 100 million, you're talking a long time.

     

    InnoDB will always do a row count when a COUNT query is issued.  So, if you do "SELECT COUNT(*) FROM table" it will scroll through and lock/unlock each row in sequence as it counts them.

  4. before writing text into a file, use addslashes().... then when retrieving, use stripslashes() before displaying.

     

    There's no reason to escape content in a text file. 

     

    The whole purpose for magic_quotes_gpc was to prevent database injection attacks, because php developers, in the day of php 3, apparently couldn't be trusted to be smart enough to prevent it.  It has nothing to do with text files, and should most certainly be disabled if possible.  In php 6 magic_quotes_gpc won't even exist (along with register_globals), so this won't even be an issue.

     

    Darkwater's response is a viable method of removing the slashes if you can not disable the directive in php.ini.

  5. So, it's something else in your code that is causing the error...your server is capable of connecting to the noaa ftp server and retrieving the file.

     

    Perhaps you are trying to get a file that doesn't exist...for example, if your variable "$row['icao']" is empty, it would generate a string like:

     

    ftp://tgftp.nws.noaa.gov/data/observations/metar/decoded/.TXT

     

    to retrieve, which doesn't exist.

  6. When the rss link is clicked, the server is delivering it in the form of a download...in other words, my browser doesn't understand that your rss file is supposed to be viewed as xml (cause it is xml).  The way to fix this is to send an xml header to the browser.

  7. Ahh, then I misunderstood your question...store the "current" state and check to see if it changed, then echo out the change the first time...

     

    <?php 
    $current_state = "";
    $display_state = "";
    
    do { 
    if ($row_StoresDb['state'] != $current_state) {
    	$current_state = $row_StoresDb['state'];
    	$display_state = $current_state;
    } else {
    	$display_state = " ";
    }
    ?>
    
    	<tr>
    		<td height=19 align=CENTER valign=TOP><b><font face="Times New Roman"><?php echo $display_state; ?></font></b></td>
    
    		<td align=CENTER valign=TOP><font face="Times New Roman"> </font></td>
    		<td align=CENTER><font face="Times New Roman"> </font></td>
    	</tr>
    	<tr>
    		<td height=17 align=CENTER valign=TOP><font face="Times New Roman"><?php echo $row_StoresDb['retailer']; ?></font></td>
    		<td align=CENTER valign=TOP><font face="Times New Roman"><a href="<?php echo $row_StoresDb['url']; ?>"> <?php echo $row_StoresDb['address']; ?> </a></font></td>
    		<td align=CENTER><font face="Times New Roman" color="#000000"><?php echo $row_StoresDb['phone']; ?></font></td>
    	</tr>
    	<tr>
    	  <td height=17 align=CENTER valign=TOP> </td>
    	  <td align=CENTER valign=TOP> </td>
    	  <td align=CENTER> </td>
      </tr>                
    <?php 
    
    } while ($row_StoresDb = @mysql_fetch_assoc($StoresDb)); ?>

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