FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » problem saving date fields
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: problem saving date fields [message #174092 is a reply to message #174087] Sat, 21 May 2011 12:12 Go to previous messageGo to previous message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma:
Member
On 21 mei, 11:29, Luuk <L...@invalid.lan> wrote:
> On 21-05-2011 10:34, Co wrote:
>
>
>
>
>
>
>
>
>
>> On 21 mei, 09:57, Luuk <L...@invalid.lan> wrote:
>>> On 21-05-2011 00:52, Co wrote:
>
>>>> On 21 mei, 00:24, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>>> > On 5/20/2011 5:00 PM, Co wrote:
>
>>>> >> I get a "1" as result.
>>>> >> Don't know what you mean with this.
>>>> >> Problem is that the date is set to 00-00-0000.
>>>> >> Is that because there is a default set in the field (00-00-0000)?
>
>>>> >> Marco
>
>>>> > As a result for what?  There's no thread here.
>
>>>> > Please use REPLY to a message, not start a new thread.  And quote the
>>>> > appropriate parts of the message, to maintain continuity.
>
>>>> > --
>>>> > ==================
>>>> > Remove the "x" from my email address
>>>> > Jerry Stuckle
>>>> > JDS Computer Training Corp.
>>>> > jstuck...@attglobal.net
>>>> > ==================
>
>>>> Luuks thought:
>>>> print $sql;
>
>>>> it returns 1, dont know what I should do with it.
>>>> Problem is that if I only change one of the dates:
>>>> arrival_date='$arrival_date',departure_date='$departure_date'
>
>>>> the other one gets to be the default value 00-00-0000.
>
>>>> Marco
>
>>> Ok, i responded in the other thread, but wanted to 'add' this:
>
>>> 09:53:29 root@test[14]mysql> insert into testDate values ('21-05-2011');
>>> Query OK, 1 row affected, 1 warning (0.00 sec)
>
>>> 09:55:46 root@test[15]mysql> select * from testDate;
>>> +------------+
>>> | SepDate    |
>>> +------------+
>>> | 0000-00-00 |
>>> | 2011-05-21 |
>>> | 0000-00-00 |
>>> +------------+
>>> 3 rows in set (0.00 sec)
>
>>> --
>>> Luuk
>
>> Luuk,
>
>> forgive me but an I a newbie.
>> Where do I need to add quotes?
>> And what does your tests say?
>
>> Marco
>
> Sorry, two seconds after my post i did see you gave  quotes around the
> dates.
>
> Only help i can give if you copy paste the output of print $sql here.
> If that gives "0000-00-00" (or another wrong date) than something is
> wrong in a piece of code you did not show here.....
>
> --
> Luuk

Luuk,

Here is all the relevant code:

$birthday_day = "";
$birthday_month = "";
$birthday_year = "";
$arrival_day = "";
$arrival_month = "";
$arrival_year = "";
$departure_day = "";
$departure_month = "";
$departure_year = "";

if ($_POST['parse_var'] == "location"){

$firstname = preg_replace('#[^A-Za-z]#i', '',
$_POST['firstname']); // filter everything but desired characters
$lastname = preg_replace('#[^A-Za-z]#i', '', $_POST['lastname']); //
filter everything but desired characters
$gender = $_POST['gender'];
$country = strip_tags($_POST['country']);
$country = str_replace("'", "&#39;", $country);
$country = str_replace("`", "&#39;", $country);
$country = mysql_real_escape_string($country);
$partner = $_POST['partner'];
$rank = $_POST['rank'];
$service = $_POST['service'];
$position = $_POST['position'];

$arrival_month = preg_replace('#[^0-9]#i', '',
$_POST['arrival_month']);
print $arrival_month;
$arrival_day = preg_replace('#[^0-9]#i', '',
$_POST['arrival_day']); // filter everything but numbers
$arrival_year = preg_replace('#[^0-9]#i', '',
$_POST['arrival_year']); // filter everything but numbers
$arrival_date = "$arrival_year-$arrival_month-$arrival_day";

$departure_month = preg_replace('#[^0-9]#i', '',
$_POST['departure_month']);
print $departure_month;
$departure_day = preg_replace('#[^0-9]#i', '',
$_POST['departure_day']); // filter everything but numbers
$departure_year = preg_replace('#[^0-9]#i', '',
$_POST['departure_year']); //
$departure_date = "$departure_year-$departure_month-$departure_day";

$birthday_month = preg_replace('#[^0-9]#i', '',
$_POST['birthday_month']);
$birthday_day = preg_replace('#[^0-9]#i', '',
$_POST['birthday_day']); // filter everything but numbers
$birthday_year = preg_replace('#[^0-9]#i', '',
$_POST['birthday_year']); // filter everything but numbers
$birthday_date = "$birthday_year-$birthday_month-$birthday_day";

$sqlUpdate = mysql_query("UPDATE myMembers SET
firstname='$firstname', lastname='$lastname', gender='$gender',
partner='$partner', country='$country', rank='$rank',
service='$service', position='$position', birthday='$birthday_date',
arrival_date='$arrival_date',departure_date='$departure_date' WHERE
id='$id' LIMIT 1");

if ($sqlUpdate){
$success_msg = '<img src="images/round_success.png" width="20"
height="20" alt="Success" />Personal information has been updated
successfully.';
} else {
$error_msg = '<img src="images/round_error.png" width="20"
height="20" alt="Failure" /> ERROR: Problems arose during the
information exchange, please try again later.</font>';
}
}

$sql_default = mysql_query("SELECT * FROM myMembers WHERE id='$id'");

while($row = mysql_fetch_array($sql_default)){

$firstname = $row["firstname"];
$lastname = $row["lastname"];
$gender = $row["gender"];
$country = $row["country"];
$rank = $row["rank"];
$partner = $row["partner"];
$service = $row["service"];
$position = $row["position"];
$birthday_date = explode("-",$row["birthday"]);
$birthday_year = $birthday_date[0];
$birthday_day = $birthday_date[2];
$birthday_month = date( 'F', mktime(0, 0, 0, $birthday_date[1]) );
$arrival_date = explode("-",$row["arrival_date"]);
$arrival_year = $arrival_date[0];
$arrival_day = $arrival_date[2];
$arrival_month = date( 'F', mktime(0, 0, 0, $arrival_date[1]) );
$departure_date = explode("-",$row["departure_date"]);
$departure_year = $departure_date[0];
$departure_day = $departure_date[2];
$departure_month = date( 'F', mktime(0, 0, 0,
$departure_date[1]) );
$email = $row["email"];
$email_work = $row["email_work"];
$mobile_phone = $row["mobile_phone"];
$office_phone = $row["office_phone"];
$office_fax = $row["office_fax"];
$home_address = $row["home_address"];
$residence = $row["residence"];
$host = $row["host"];
$bio_body = $row["bio_body"];
$bio_body = str_replace("<br />", "", $bio_body);
$bio_body = stripslashes($bio_body);
$website = $row["website"];
$youtube = $row["youtube"];
$facebook = $row["facebook"];
$twitter = $row["twitter"];
/////// Mechanism to Display Pic. See if they have uploaded a pic or
not //////////////////////////
$check_pic = "members/$id/image01.jpg";
if ($gender != "f") {
$default_pic = "members/0/image01.jpg";
} else {
$default_pic = "members/0/image02.jpg";
}

if (file_exists($check_pic)) {
$user_pic = "<img src=\"$check_pic?$cacheBuster\" width=\"50px\" /
> "; // forces picture to be 100px wide and no more
} else {
$user_pic = "<img src=\"$default_pic\" width=\"50px\" />"; // forces
default picture to be 100px wide and no more
}


} // close while loop

<table width="100%" border="0" align="center">
<tr>
<td width="34%"><strong>Date of Arrival</strong></td>
<td width="33%"><strong>Date of Departure</strong></
td>
<td width="33%"><strong>Birthday</strong></td>
</tr>
</table>
<table width="100%" border="0" align="center">
<tr>
<td width="34%">
<select name="arrival_day" class="formFields" id="arrival_day">
<option value="<?php print "$arrival_day"; ?>"><?php print
"$arrival_day"; ?></option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="arrival_month" class="formFields" id="arrival_month">
<option value="<?php print "$arrival_month"; ?>"><?php print
"$arrival_month"; ?></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="arrival_year" class="formFields" id="arrival_year">
<option value="<?php print "$arrival_year"; ?>"><?php print
"$arrival_year"; ?></option>
<option value="2011">2013</option>
<option value="2011">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
</select> </td>
<td width="33%">
<select name="departure_day" class="formFields" id="departure_day">
<option value="<?php print "$departure_day"; ?>"><?php print
"$departure_day"; ?></option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="departure_month" class="formFields"
id="departure_month">
<option value="<?php print "$departure_month"; ?>"><?php print
"$departure_month"; ?></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="departure_year" class="formFields" id="departure_year">
<option value="<?php print "$departure_year"; ?>"><?php print
"$departure_year"; ?></option>
<option value="2011">2015</option>
<option value="2011">2014</option>
<option value="2011">2013</option>
<option value="2011">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
</select> </td>
<td width="33%"><select name="birthday_day"
class="formFields" id="birthday_day">
<option value="<?php print "$birthday_day"; ?>"><?php print
"$birthday_day"; ?></option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="birthday_month" class="formFields" id="birthday_month">
<option value="<?php print "$birthday_month"; ?>"><?php print
"$birthday_month"; ?></option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="birthday_year" class="formFields" id="birthday_year">
<option value="<?php print "$birthday_year"; ?>"><?php print
"$birthday_year"; ?></option>
<option value="2011">2013</option>
<option value="2011">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
<option value="1989">1989</option>
<option value="1988">1988</option>
<option value="1987">1987</option>
<option value="1986">1986</option>
<option value="1985">1985</option>
<option value="1984">1984</option>
<option value="1983">1983</option>
<option value="1982">1982</option>
<option value="1981">1981</option>
<option value="1980">1980</option>
<option value="1979">1979</option>
<option value="1978">1978</option>
<option value="1977">1977</option>
<option value="1976">1976</option>
<option value="1975">1975</option>
<option value="1974">1974</option>
<option value="1973">1973</option>
<option value="1972">1972</option>
<option value="1971">1971</option>
<option value="1970">1970</option>
<option value="1969">1969</option>
<option value="1968">1968</option>
<option value="1967">1967</option>
<option value="1966">1966</option>
<option value="1965">1965</option>
<option value="1964">1964</option>
<option value="1963">1963</option>
<option value="1962">1962</option>
<option value="1961">1961</option>
<option value="1960">1960</option>
<option value="1959">1959</option>
<option value="1958">1958</option>
<option value="1957">1957</option>
<option value="1956">1956</option>
<option value="1955">1955</option>
<option value="1954">1954</option>
<option value="1953">1953</option>
<option value="1952">1952</option>
<option value="1951">1951</option>
<option value="1950">1950</option>
</select> </td>
</tr>
</table>
<table width="100%" border="0" align="center">
<tr>
<td width="34%"><strong>Partner</strong></td>
<td width="33%"><strong>&nbsp;</strong></td>
<td width="33%"><strong>&nbsp;</strong></td>
</tr>
</table>
<table width="100%" border="0" align="center">
<tr>
<td width="34%">

Sorry for the length
Marco
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: is dis da place?
Next Topic: foreach in reverse
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 18:27:24 GMT 2024

Total time taken to generate the page: 0.04647 seconds