473,597 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why do I get an parse error in the first line? Please help. Thanks in advance.

3 New Member
Expand|Select|Wrap|Line Numbers
  1. <?php
  3. int DMYToExcelSerialDate(int nDay, int nMonth, int nYear)
  4. {
  5.     // Excel/Lotus 123 have a bug with 29-02-1900. 1900 is not a
  6.     // leap year, but Excel/Lotus 123 think it is...
  7.     if (nDay == 29 && nMonth == 02 && nYear==1900)
  8.         return 60;
  10.     // DMY to Modified Julian calculatie with an extra substraction of 2415019.
  11.     long nSerialDate =
  12.             int(( 1461 * ( nYear + 4800 + int(( nMonth - 14 ) / 12) ) ) / 4) +
  13.             int(( 367 * ( nMonth - 2 - 12 * ( ( nMonth - 14 ) / 12 ) ) ) / 12) -
  14.             int(( 3 * ( int(( nYear + 4900 + int(( nMonth - 14 ) / 12) ) / 100) ) ) / 4) +
  15.             nDay - 2415019 - 32075;
  17.     if (nSerialDate < 60)
  18.     {
  19.         // Because of the 29-02-1900 bug, any serial date
  20.         // under 60 is one off... Compensate.
  21.         nSerialDate--;
  22.     }
  24.     return (int)nSerialDate;
  25. }
  28. print (nSerialDate);
  30. ?>
Oct 10 '09 #1
5 1779
6,050 Recognized Expert Expert
Because that is not PHP code. PHP is not a strongly type language, ergo variables and functions do not need (cannot have) their types declared.

Consider the following:

Expand|Select|Wrap|Line Numbers
  1. // valid way of declaring a function - notice the 'function' keyword.
  2. function my_function($param1, $param2) {}
  3. // invalid way of declaring a function - lacks the 'function' keyword and also specifies return type of function
  4. int my_function($param1, $param2) {}
  5. // also invalid, same as above, but also specifies type of parameters (please see next example also)
  6. int my_function(int $param1, int $param2) {}
  7. // you can 'type-hint' certain values for your parameters, such as 'array'
  8. // and classes
  9. function my_function(array $param1, my_class $param2) {}
  11. // correct way to define a variable
  12. $my_variable = 1;
  13. // incorrect
  14. int $my_variable = 1;
Hope this helps,

P.S. Welcome to the forum!
P.P.S Please use code tags when posting code to the forum. That can be done as [code] your code here [/code].
Oct 11 '09 #2
3 New Member
Thanks for the reply Mark,
I simply just wanted to convert a Date YYYYMMDD to an Excel serial date, using .php code. I'm not having much success as I am new to .php.
Oct 11 '09 #3
6,050 Recognized Expert Expert
Read some tutorials, and you'll be able to do it yourself based on the above algorithm.
Oct 11 '09 #4
3 New Member
Thanks for the confidence in me. At least I can gather from your reply that what I whant to do is possible.
Oct 11 '09 #5
6,050 Recognized Expert Expert
Sure it is - all you're really doing is some math, which PHP handles just like any other language. I would give you a head start, but I have to run out.

Oct 11 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Steven | last post by:
I got a "Parse error: parse error in ..." in this line: if(empty($_POST){ ..... But if I fist assign $ssn=$_POST; and then if(empty($ssn){ ... it is working. Any advice? Thanks in advance.
by: Brett Romero | last post by:
I get this error when I try to run my ASP.NET app on our server: Server Error in '/' Application. -------------------------------------------------------------------------------- Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
by: floofy | last post by:
Hi, I am extremely new to programming and I'm taking a beginner's course right now. We were given a .cpp code to correct so that it will compile. I've already fixed a couple errors but Dev-C++ still gives me "parse" in the compiler window on this specific line: for int = 0; < howmany + i++; I don't exactly want to post the entire code, but I'm not sure if that single line is sufficient...parse error is some sort of parenthesis...
by: jecha | last post by:
I don't know why I continue getting such errors .With this one I can't even locate where the problem is.Its a database class for accessing information from a website database. <? /** * Database.php */ include("constants.php"); include("db_conn.php"); class Users {
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.