FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problem with my script....





KXWB400
Hi
I am trying to make a script that updates a hidden feild with a week number of a date wich I type in a textfield, and submits to the database.

I keep getting the error message: Warning: mktime() expects parameter 4 to be long

The script looks like this:

Code:
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table align="left">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Fooddate:</td>
      <td><input type="text" name="Fooddate" value="<?php echo date('m-d-Y'); ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Meal:</td>
      <td><input type="text" name="Meal" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Insert record" /></td>
    </tr>
  </table>
  <input type="hidden" name="Transact_ID" value="" />
  <input type="hidden" name="Emp_no" value="<?php echo $row_employee['no']; ?>" />
  <input type="hidden" name="C_Date" value="<?php echo date('m-d-Y'); ?>" />
  <input type="hidden" name="U_Date" value="" />
  <input type="hidden" name="U_User" value="" />
  <input type="hidden" name="Company" value="<?php echo $row_employee['company']; ?>" />
  <input type="hidden" name="Week" value="<?php echo $testvecka; ?>" />
  <input type="hidden" name="MM_insert" value="form1" />
  <?php
$date = $_POST['Fooddate'];
list($month, $day, $year) = split('[/.-]', $date);
$testvecka = date('W', mktime(0, 0, 0, date($month) , date($day) , date($year)));
?>
</form>

The point with it is that I don't want to have a static date, I want it to be dynamic and that has turn my hair grey Very Happy

Can some one please help me?
Best Regards
Jimmy
Peterssidan
You split up $_POST['Fooddate'] to something like $month='09', $day='17', $year='2009';
after that you pass these numbers as argument to the date function. date take a format string, not a number so I have no idea what the result is.

Maybe what you want to do is to remove the date calls at that line:
Code:
$testvecka = date('W', mktime(0, 0, 0, $month , $day , $year));


I'm not sure exactly how php's integer <-> string automatic casts works so maybe you have to cast the values like (int) $month, and so on.
rickylau
First, I don't see any error message (even with something like date($month), I run the script at Frihost's server). It run as what I expected. But surely the using of date here is not proper and it should be remove for safety.

Second, for casting string into integer use (int)$variable is OK, also intval ($variable) as well. But as PHP manual mentioned these operations are optional because PHP will automatically do so if needed. (But for assurance, do it manually)
blueray
I did a fast test and saw no error also.

The use of date should be fine as the default param values of mktime was something date('Y') etc.
Which version of php you are currently in use ?
KXWB400
Just to be clear, I am a hobbie programmer with not so much skills in PHP and using dreamweaver with the latest version of xampp (apache and mysql).

I'm building a lunch ordering system for my work.

The tabel that i want the data inserted to is: matsal.transactions, with the following columns:
Transact_ID (int) auto increase
Emp_no (varchar)
C_Date (varchar)
U_Date (varchar)
U_User (varchar)
Fooddate (varchar)
Meal (varchar)
Company (varchar)
Week (varchar)

Here comes the web part:

index.php the logon page, check the user against the database and access level, sends the username as a session variable and put the current week in url to the next page.

logedon.php
Lists info about the user such as employee number, company, name, date and week.

this page is opening a PDF file linked to the current week.

sens i allready have the info about the user, I use it in the insert form action. The only thing i want the user to do is insert a date in "Fooddate" and a meal number (1 - 5) and submit.

Of that date in fooddate I want to send the week number of that date with a hidden object.

And the list all of my orders based on the meny week.

Do you want the code to the whole site?

Thx for all the good replies.
Related topics
phpbb problem....
Need a script - navigation
Navigation Script (javascript) Help Please!
I can't upload my Database SQL script ! Helllppppp!!!!
problem with a php randomizer script
Php script Cod server stats
SDRAM vs DDRAM
A PHP problem !
MySQL DB Backup script - minor problem
Script Problem
Problem with a script
Script problem
PHP login script problem
Problem with galary script
" Fatal error: Allowed memory size of 52428800" bl
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.