Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





I Write A Date Calculator, But There Always Get A One-day-distance Wrong


<?php
/**
* check ine year is a leap year, and return the month day array
*
* @param int $year **the year must bigger than zero**
* @return array
*/
function is_leap_year($year){
$year=floor($year);
if ($year<=0) {
return false;
}
$flag = false;//leap year flag

/*
* check the year
*/
if ($year%100==0) {
if ($year%400==0) {
$flag = true;
}
}
else {
if ($year%4==0) {
$flag = true;
}
}
$mon[0] = $flag;//leap year flag
$mon[1] = 31;
$mon[2] = $flag?29:28;
$mon[3] = 31;
$mon[4] = 30;
$mon[5] = 31;
$mon[6] = 30;
$mon[7] = 31;
$mon[8] = 31;
$mon[9] = 30;
$mon[10] = 31;
$mon[11] = 30;
$mon[12] = 31;
return $mon;......




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
HTML/Javascript Date Calculator
It's based on the Luna dates its been done using HTML/Javascript, but I now realise I require it in PHP. and my PHP knowledge is very bad and so was wondering if anyone could help out.

View Replies !   View Related
GMT Date Set Wrong?
If I do a script like this: PHP Code:

View Replies !   View Related
Date()'s Wrong.
so I'm using

echo date ("r");

and it's returning the time an hour late. Is that set wrong on the server? And if so how to go about fixing that. email them I guess? I mean, I guess I could learn to parse nist.gov output, but that seems like alot of trouble for something so small. Since I don't have another box to check with, could someone click my site link below and tell me if the time in the nav bar is late for them also?

View Replies !   View Related
Date/time Displaying Wrong
How do I set the time display to echo the time, in the timezone the user is in and not the server time. For somereason im in eastern timezone and the host server i9s in central and the time displayed on my laptop is in central.

View Replies !   View Related
Date Function Sometimes Returns The Wrong Day
I have the following php code:

function Today2SQLDatetime () {
$today = date ("Y-m-d H:i:s");
print "date ("Y-m-d H:i:s") returned $today<br>";
return $today;
return date ("Y-m-d H:i:s");
} // Today2SQLDatetime

Most of the time this works just fine. For today, for example, it
returns "2005-02-11 xx:xx:xx". But sometimes, for some odd reason it
returns "2005-02-12 xx:xx:xx"! My theory is that since this is on my web
page and since PHP is running under Apache and since this happens every
once in a while that perhaps one of Apache's subprocess has the wrong
idea of my time zone and is actually pointed into tomorrow. Any ideas?

View Replies !   View Related
Mktime Returning Wrong Text Date
I am pulling numerical month data from the DB and converting it to a text format using mktime() and date() functions. PHP Code:

View Replies !   View Related
Date Displaying And Storing In MySQL While In Wrong Timezone
I've only used php to display the current date but I can see that I'm not in the same timezone as the server is. Its 5 hours ahead and I can't get it to show the date as Eastern Time.

I'm developing a site for a non-profit slopitch league so they can submit score sheets and track their season. 2 teams must submit a score sheet for their team within 72 hours of having played the game. Then they are not allowed to enter the score sheet without the administrator's permission. Code:

View Replies !   View Related
Group-Office / IMAP EMail - Wrong Date Display ??!!
I installed the Community Version of the Group-Software GroupOffice (http://www.group-office.com) on my Webserver.

Group-Office got a module for webmail (IMAP/POP3 eMail-Server). I copied my mail on my IMAP-Server. There are two diffentent views form the mails, a Listview and a Detailview of the selected mail. I think in the Listview there is a wrong eMaildate - It´s the date the mail saved on the server.

In my case there are many mails with the same date, because I copied a lot of them at the same day in the IMAP Folder. The Detailview displays the right emaildate, the date of sending the mail.

There are two different PHP-Files, one for the listenview (messages.php) und one for the datailview (message.php). I think I found the lines of each file for retrieving and displaying the dates. Code:

View Replies !   View Related
Can You Write Date(F) + 1 Without Using Variables?
without having to write out a list of if statements I would like to be able to write this month, the next month and the month after in long form, I've tried to write it as date(F)+1 or date(F)+2 to get December and January. I know I could write out if statements and call in a variable, but was just curious if anyone had another idea.

View Replies !   View Related
Distance Between Zip Code
I am looking for an object that can have two US zip codes sent to it and then return the distance between the two zip codes. Or if there is a function that will return the distance between two major cities. Has anyone seen anything like this on the web?

View Replies !   View Related
Calculating Distance
Does anyone know of a service or script where you can enter two addresses and get a distance between, or do so by range?  I know mapquest has something, but I'm looking for something a little less expensive and basic?  If anyone has any ideas, that would be great.  BTW, it must work with PHP and MySQL

View Replies !   View Related
Distance Learning
Does anybody know of any (free) online distance learning courses in web-development with php, targeting beginners, from the keyboard and text editor up? My first Google attempts turned up pages of "online schools" that want you to enroll and pay a fee. But nothing of substance that was free.

View Replies !   View Related
States And Distance
php so accept my appologies if i sound idiot somewhere in my post :D i want to make a property dealers search form in USA. that will be like Enter your zip:
enter distance from you: (5/8/12 etc Miles) and the script should show the results from database of dealers based on the user's zip and the distance he entered.

View Replies !   View Related
Sort Distance
I am a newbie at php and would like to know how i would go about sorting ads by distance. The distance is currently echo'd using the following method.

$d = round(distance($lati[0], $long[0], $lati[1], $long[1],"M"));
echo $d;

at the moment the $d is using distance which is a function that calculates the distance between two given postcodes using an sql table in the database. I have got it to work so far so that it displays the distance in miles beside each ad but would now like to know how I would go about ordering or sorting the ads by $d echo'd.

View Replies !   View Related
Zip Distance In A Square, Not Radius
I have successfully created a zip code radius search, but the performance is
unacceptable.

I have two tables. The first is 52K zip codes w/lat and long. The second is
3K national business addresses.

Using the zip code 10010, it takes almost 60 seconds to return 122
businesses within a 25 mile radius. This slowdown is almost entirely due to
the query radius distance formula.

I wonder if someone knows the formula to calculate the distance within a
given square. Would this increase performance? I presume the results would
include zips in the "corners", but performance boost might be worth it.

View Replies !   View Related
ORDER BY Zip Code Distance
I have successfully converted the ASP code included in the following article
to PHP:

As described the high and low latitudes and longitudes are pre-calculated
and passed to the query.

SELECT *
FROM Locations
WHERE Latitude <= $HighLatitude
AND Latitude >= $LowLatitude
AND Longitude >= $LowLongitude
AND Longitude <= $HighLongitude

I then calculate the actual distance using the latitude and longitude for
each zip returned.

This works great and saves lots of cycles. The downside to this technique is
the inability to sort by distance. Can someone suggest a simple way to
calculate and ORDER BY distance within the query?

View Replies !   View Related
Calculating Distance With Zipcodes
I have a DB of zipcdoes that includes it's lat. and long. and some other stuff. Is there an easy way of searching "within a 100 miles" etc of someone's location?

View Replies !   View Related
Returns The Distance Between Two Zip Codes
I have this code that returns the distance between two zip codes and will return a radius of zips within so many miles.

I am wanting to add onto this code to have it select from a new table that I have all of the rows of zip codes within that range. This new table would have name, address, zip, ect. Code:

View Replies !   View Related
Display Results According To Distance
I have a php/mysql driven website. On my search bar I have the option of searching by zip code. I have the function to find the radius of the surrounding zip codes. But I want to display the result along with my information from the other table.

An example would be:

I want to search for ads around my zip code for a range of 20 miles. The class I have will find all the zips and get their distances plus will sort them by closest to farthest. My problem is I want to display the records according to the distance provided. I heard of doing a sort with php but I am not sure which route to go.

I hope someone has found out how to do it, because this is the only thing left to do in order to launch the site.

View Replies !   View Related
Distance Calculation Based On ZIP Codes,etc (need Help)
Does not anyone know how distances are calculated on sites like mapquest.com and verizon.com.

You type in the ZIP code or some other information and they tell you how far something is from it or businesses in a particular radius.

View Replies !   View Related
A Calculator Bug
i just created this benefits calculator, but it doesn't work, there is
no changes happen after submitting,
<html>
<head>
<title> |||Stocks Calculator||| </title>
<style type="text/css">
<!--
body {font-size: 14pt}
..heading {font-size: 18pt; color: red}
-->
</style>
</head>
<?php
if (!isset($_post['submit']) || $_post['submit'] != 'Calculate')
{
$_post['price'] = "";
$_post['sell'] = "";
$_post['pricec'] = "";
$_post['sellc'] = "";
$gain = (($_post['sell'] - $_post['sell'] * $_post['sellc']) -
($_post['price'] + $_post['price'] * $_post['pricec']));
} else {
print("Still Shit Happens");
}
?>
<body>
<div align="center" id="div1" class="heading">
<b><i><u>Stocks Calculator</u></i></b></div>
<p class=blurb>Enter all the data required to get your gain calculated
by our gain calculator for stocks<br>
*Please notice: Approximatly value for commisions in the Egyptian stock
exchange is 0.005% - 0.006%.</p>

<form action="<?php echo $_server['php_self']; ?>" method="post">
<p>Buy Price:
<input type="text" size="10" name="price" value="<?php echo
$_post['price']; ?>">
<p>Commision:
<input type="text" size="5" name="pricec" value="<?php echo
$_post['pricec']; ?>">
<p>The Price you want to sell at:
<input type"text" size="10" name="sell" value="<?php echo
$_post['sell']; ?>">
<p>Commision:
<input type="text" size="5" name="sellc" value="<?php echo
$_post['sellc']; ?>">
<BR><BR>
<P><B>Net Gain :</B> <?php echo $gain; ?>
<p><input type ="submit" name="submit" value="Calculate">
</form>
</body>
</html>

View Replies !   View Related
Calculator
is it possible if i want to calculate the product * quantity with just scrolling and shows at the price without any button? If it is.. which method should i use? javascript?

View Replies !   View Related
Finance Calculator
I just got a question I was wondering if there was a way to build finance calculator in php. Where basicly it does a basic calculation. and output a results.. Is the possible or if anyone know how this can be done I would appreciate it.

View Replies !   View Related
Perfect Age Calculator
I am looking for a perfect PHP age calculator which takes someones date of
birth as an argument and returns the person's age.

I went over several tutorials, help and newsgroups an found lots of
calculators, tried many times to make the perfect script but did not
find/make the perfect one.

Simple test:

if my birthdate is 07-07-2004 (dd-mm-yyyy) and today is 07-07-2005 then i
should be 1 year old

if my birthdate is 07-07-2004 (dd-mm-yyyy) and today is 06-07-2005 then i
should be 0 years old

Lots of scripts i've found did not pass this test succesfull, so if someone
can point me to the 'golden' script

View Replies !   View Related
PHP Shipping Calculator
I need to build my own shipping calculator, for UPS shipping, and maybe others like FedEx or ground Mail. It's going to be built in to a new e-commerce thing.

For UPS, The Zones and Rates tables are available as CSV files, which is very nice of them.

Has anyone here built one of these before? Is there anywhere I can find something pre-cooked, or at least get some advice before I start?

View Replies !   View Related
Calculator Build
Im developing a simple calculator, for a roofing product company, that will compute our clients project requirements, based on three different variables: roof pitch, panel length and product type. I have everything under control except the roof pitch and run, but let me try to clarify.

There are 10 different roof pitches and unlimited run lengths, the number of product required increases with pitch and run increases. See picture below.

Without defining every product increase manually (as there are many products I will have to use this with,) is there a way to incrementally increase the product per roof pitch and run, or does anyone have a better solution?

View Replies !   View Related
A Calculator Of Sorts
i need to create a calculator of sorts, that takes user input like this:
Primary Magic: 279 75% thoughtful Harness Ability: 277 69% thoughtful

except there will be aproxamatly 20 lines like that, each with a different "title" for the number)and picks out each set : (Primary Magic: 279 75% thoughtful.... is 1 set), finds the corrisponding set in a database, or array, and calculates how much is needed to gain a level. i don't even know where to begin with this. i've spoken with people who have created their own calculators, but they are no help. one said he uses arrays, another says he uses mysql and another says he uses an excel file for the "database" part.

View Replies !   View Related
Creating Calculator
My dad would like an online calculator created for his grain buisness. It is going to allow customers to type in their grains moisture and the amount of grain, then when the calculate button is pushed the customer will find out how much it will cost them to do dry their grain.

I was doing well converting my dad's Microsoft Excel spreadsheet formulas into the calculator form when I got stuck. Part of my dads formula wants to match the moisture level that the customer originally typed in, with a cordinationg price. In order for this to work I'd need two very long collums of moisture levels/prices.

How do I get my calculator to use some form of a spreadsheet to get information? Is it even possible?

View Replies !   View Related
SIMPLE CALCULATOR
I want to program a simple calculator in php language combining with html, but I have a problem:

when using <forms> for one value ex:
<input type="submit" name="numer1" value="9"/>,

I want this value to be stored in an array(); in my code.

View Replies !   View Related
Expenses Sharing Calculator
Expenses sharing calculator, but i have no idea for manage entry for expansive
between members like, if $100 shared between 3 member then if 1 member give $25 to one member (which give $100), so how we manage these things in table structure give me some idea how i manage all the things ...

View Replies !   View Related
Writing A Calculator Function
I've already done a nice little code to translate a floating number into a minute-and-second format to calculate paces for running races. Now, I need to make this a function. To be honest, I have no idea how to write the function and was wondering if someone could help. Here's the basic code:

View Replies !   View Related
UPS Rate Calculator Trouble
The class I am using from Zend to get UPS shipping rates is supposed to return results in this format:

UPS Ground 8.0 lbs $5.24
UPS 2nd Day Air 8.0 lbs $12.43
UPS Next Day Air 8.0 lbs $26.90

But it is not getting the rate, or at least not displaying it properly. Its showing like:

UPS Ground,nUPS 2nd Day Air,nUPS Next Day Air,n

Can someone look at the script and maybe point out what might be wrong? I'm running php 4.4.5 with cURL enabled. I do not get any error messages, so I assume the connection to UPS is fine. Code:

View Replies !   View Related
Mortgage Calculator Function
I'm still pretty new to functions and haven't used them much. I wanted to make a function that takes user input data and calculates a monthly payment for a mortgage. I'm not sure if the actual syntax is wrong, or if it just comes down to the math- but its not working. this is the form:

page1.php
<form action="mortgage_calculate.php" name"MortgageCalculator">
<table border="0" width="400">
<caption> Mortgage Calculator </caption>
<tr><td>List Price: <input type="text" value="listprice" /></td></tr>
<tr><td>Rate: <input type="text" value="rate" /> %</td></tr>
<tr><td>Downpayment: <input type="text" value="downpayment" /></td></tr>
<tr><td>Years: <input type="text" value="25" /></td></tr>
<tr><td><input type="submit" name="submit" value="Calculate" /></td></tr>
</table>
</form>........

View Replies !   View Related
Double Check My BMI Calculator
just want to make sure i programmed it right.  also  the action is going to be the thread number would it automatically carry out the action and post it in the thread number? or would i have to do something in order for it to post in that thread.

<?php 

$height= trim($_POST['height']);
$height=str_replace(',','.');
$weight=trim($_POST['weight']);
$height=str_replace(',','');
$height=str_replace('.','');



if ($_POST['height']||$_POST['weight']=="true") 
{ $heightwo=$height/2; 

 $total=$weight/$heightwo *703;}
 
 echo "your Mass Body Index is:"($total);

View Replies !   View Related
Control Calculator Expression Logic
I am building a PHP scientific calculator, users can perform calculation by just typing like normal mathematical expressions, e.g "(2+3-4^6)/33.3* 4!" so the result will be calculated accordingly, but I have a problem that, when malicious users try to put a mathematical expressions that is very long enough and takes a very heavy load of processing which might make my web server down. Such as

"9999999999999999999999999999999999999999999999999999999 * 999999999999999999999999999999"

So I thought of limiting the expressions that users can input up to 50 characters long, but this is still not a good idea, because heavy calculations does not necessarily depends on the length of the expressions, such as

//This does not make my computer load heavily
"1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1"

//But this one takes quite long and consume high processing power.
"999999999^99999"

So I want to know, is there a logic that can actually determines the result which might consume high processing which can solve my problem ? or is there a good scientific calculator library that you might want to share ?

View Replies !   View Related
Credit Card Monthly Balance Calculator
I want to make a calculator that shows what your interest rate would be.
The key is that it would output a new row per month with the interest charge, the next payment, etc. Not the single line, generic ones that are all over the web.

Sample:
User inputs:
- Loan amount
- Interest rate
- minimum payment rate (usually between 1-3%)
- monthly payment desired

Here is the meat:
The output would return anywhere from 1-400 rows, each explaining the current balance and the interest accrued for that month.

View Replies !   View Related
Get The Todays Date- Yesterdays Date And Tomorrows Date
I get the todays date- yesterdays date and tomorrows date, like so:

$yesterday = date ("Y-m-d", mktime (0,0,0,date("m"),(date("d")-1),date("Y")));

$tomorrow = date ("Y-m-d", mktime (0,0,0,date("m"),(date("d")+1),date("Y")));

$actualdate = date("Y-m-d");

Which returns the date in the format "200-11-13" But I need to add 13 hours to all three - how owuld I do this?

View Replies !   View Related
What Im I Doing Wrong
I am printing out how many featured items are in a database, and this is what i got. PHP Code:

View Replies !   View Related
What's Wrong With This Url?
i cannot open requested page user_cp_profile.html and at the same time send user id using url. can someone tell me what wrong with the url. PHP Code:

View Replies !   View Related
What's Wrong W/this (if / Or) ?
When ppmode is set to "cancel" or "thankyou", the header and exit are still
processed.
I'm trying to search on "if" and "or" in google, but it keeps removing "or"
from my searches.

Is there something wrong w/this ?

if (($ppmode != "cancel") or ($ppmode != "thankyou"))
{
header("Location: index.php");
exit();
}



View Replies !   View Related
Wrong Id
I have a table named 'choose' with the fields site_id, user_id and values, with 2 rows :

row1 :
site_id = 1
user_id = 2
value = 0

row2 :
site_id = 4
user_id = 2
value = 0

I use the following form, that get's it's info from another table Code:

View Replies !   View Related
What Is Wrong With My Include()?
Can someone tell me why this works:

View Replies !   View Related
Wrong Headers
I just transfered and patched up some files because I moved them from Linux/PHP/Apache/mySQL to Windows XP Home/PHP/Apache/mySQL.

I fixed all the problems that come up, but, when I load the page in IE6, it reloads a bunch of times and just loads normally.

I tried the best I can to make the page HTML 4.01 Transitional. So, on Linux, after I patched the page to be HTML 4.01 Transitional I put a link for my visitors to validate my page if they want to.

So I notice also, that when I validate the page, I rarely get it to work. 90% of the time, this is what I receive from the W3C validator:

Quote: I got the following unexpected response when trying to retrieve <http://*****/>:

500 Bad header: ' <img src="/images/menu/other_stuff-off.gif" alt="Other Stuff" name="menu-other_stuff" width="186" height="17" border="0">'

Please make sure you have entered the URI correctly.

I get this error most of the time, but sometimes there is a different part of my PHP HTML output in the page. And then, when it works, half of the page is trimmed off, thus, I get errors about my page not being HTML 4.01 Transitional.

I tried a couple experiments with my layout code, and the same code makes the browser reload, and reload... I've tried debugging my layout code but it brought up nothing...

I switched from the PHP module to using the CGI executable. Some things changed: The page no longer reloads repetitively; when the validator fails, I sometimes get a 'Header too long' message; using the validator brings success more often, but other letters are in the output (degree marks, little squares -- these don't appear when viewing the source of the page in IE6).

Anybody know why this header is being sent by my server?

*Note* I am not trying to load an image. I am trying to load a dynamic PHP page.

View Replies !   View Related
What's Wrong With This Code?
I keep getting parse errors on line 10 (the "if (isset($LOGINID)) {" line). Can any of you figure out why the hell I keep getting this? Is is just something simple I'm overlooking? And if you have any comments on my code (security, structure, tips, etc), I'd like to know as well...

[edit] Oh yeah, the db_connect, db_array, db_query, and decrypt functions are all defined in database.php and crypt.php. PHP Code:

View Replies !   View Related
What's Wrong In This Code
$link = mysql_pconnect ($DB_SERVER, $DB_LOGIN, $DB_PASSWORD);
$selectStmt = "SELECT * FROM user_profile WHERE userid = 'david'";
if (!($result = mysql_db_query($DB, $selectStmt, $link))){
header("Location:http://$HTTP_HOST/$DOCROOT/error.html");
exit();
}

here is the case, the userid 'David' is NOT in the table 'user_profile', the program should launch the error.html, and exit(), But it is not.


View Replies !   View Related
What's Wrong With This Php Code?
I put the following php code inside my index.html page. I upload it to my host server (free.prohosting.com), change the extension to php (and another one with php3)and CHMOD it to 644. When i viewed it in a browser, the normal html appeared but the items inside the php code failed to appear. Can somebody help me to confirm whether there is something wrong with my php code (it is a news grabber code) or is it because my webhost don't support php (the unofficial FAQ says that the server support php). If there is something wrong with my php code, here is the code: PHP code:

View Replies !   View Related
What Is Wrong With Cookies?
I use the following code to check the user who logins against a database.Then the user is redirected either to loginok.php or loginfailed.php PHP Code:

View Replies !   View Related
What Am I Doing Wrong With This Regex
I'm just trying to check and see if this name is valid. I submit things like "12345" and it evaluates to true...

function checkName ($name)
{
$status = FALSE;
$pattern = "/^[A-Za-z]+$/";
if (preg_match($pattern, $name));
$status = TRUE;
return $status;
}

View Replies !   View Related
Preg_replace - What Is Wrong Here?
preg_replace - What is wrong here?

Suppose I have this:

$words = array('piece','people');
$profile_text = "I would like to meet people to help me to work in the
world piece project.";

$marked = MarkWords($profile_text, $words);

Should return the same sentece but with the 2 words replaced with the
<span> tag, am I wrong?

function MarkWords($profile_text, $words){
for($i=0; $i<count($words); $i++){
$patern[$i] = "/@".$words[$i]."/";
$replace[$i] = "<span
style='color:white'>".$words[$i]."</span>";
}
// print_r($patern);
// print_r($replace);

$pro = preg_replace($patern, $replace, $profile_text);
return $pro;
}

View Replies !   View Related
Something Wrong With $_POST
I don't seem to be able to access the keys in an associative array.

I have a script that dynamically generates a form. The form element
names are generated based on image filenames, so I can't just access
them the normal way in the form handler script. I tried looping through
the $_POST array like this:

foreach ($_POST as $key=>$value)
{

echo $key.'=>'.$value.'<br>'
}

and i get this output:

0=>Pay
1=>Pay
2=>on
3=>on
4=>tn__DSC2602.jpg
5=>tn__DSC2603.jpg

Thos numbers are where I expected to see the form element names. Can
anyond advise me on why this is happening?

View Replies !   View Related
PHP.ini File Wrong?
I run a test server of apache/php/mysql on my laptop. I just switched from one to another and I'm moving everything over. I downloaded the latest versions of each. (Found that apache 2.0 doesn't work very well and went back to 1.3)

Everything is working, DBs are being hit properly and such except:

$SERVER_ADDR is no longer being passed back to PHP. When I run PHP_INFO() it shows up there as &#39127;.0.0.1' as expected, but I can't pick it up in my code. I'm guessing there is something going on with the variables I have turned on/off. Any ideas?

View Replies !   View Related
What's Wrong With My Script?
<?php
include"dbconn.php";
$db=mysql_select_db(creative_Articles,$connection) ;

$Parent="SELECT DISTINCT 'Cat_Parent' FROM Category";

$mysql_Parent=mysql_query($Parent);

while ($row=mysql_fetch_array($mysql_Parent))
{
$Cat_Parent=$row["Cat_Parent"];

echo "$Cat_Parent";
}
?>

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved