Jump to content

Date() stopped working


BadGoat

Recommended Posts

Hello!

I wrote a little script which uses the MySQL date datatype which does not seem to be working at the moment. It worked just fine when I wrote it on my local machine, but it is no longer working now that it's up on the host. Can someone take a look and see if I did something wrong, or if it can be optimized to work in most situations?

$sip=$_POST['sip'];
$eip=$_POST['eip'];
$nic=$_POST['nic'];
$city_id=$_POST['city_id'];
$country_id=$_POST['country_id'];
$company_id=$_POST['company_id'];
$contact=$_POST['contact'];
$phone=$_POST['phone'];
$e1=$_POST['e1'];
$e2=$_POST['e2'];
$e_ver=$_POST['e_ver'];
$updated= date('M j Y');

$sqlquery = "INSERT INTO ip_block VALUES('','$sip','$eip','$nic','$city_id','$country_id','$company_id','$contact','$phone','$e1','$e2','$e_ver','$updated')";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query !");
$sqlquery = "SELECT * from ip";


and then where the date is echoed:

<tr>
    <td class="selcol1">Date Updated</td>
    <td class="selcol2">' .$updated. '</td>
</tr>
Link to comment
Share on other sites

[quote author=Barand link=topic=104530.msg417065#msg417065 date=1155765040]
[quote author=BadGoat link=topic=104530.msg416989#msg416989 date=1155757051]
Yep, changing the data type from date to text fixed it. :)

Many thanks!
[/quote]

Bad choice. You should've gone with otuatail's solution.
[/quote]

Yes, this is because you will run into troubles if/when you need to perform things such as sorting on the date.
Link to comment
Share on other sites

[quote author=Barand link=topic=104530.msg417065#msg417065 date=1155765040]
[quote author=BadGoat link=topic=104530.msg416989#msg416989 date=1155757051]
Yep, changing the data type from date to text fixed it. :)

Many thanks!
[/quote]

Bad choice. You should've gone with otuatail's solution.
[/quote]

I said a solution just for inserting date... and he likes to handle date('M j Y'); will return "Aug 16 2006"... for inserting these kind of date format "TEXT" field is easy.
Link to comment
Share on other sites

[quote author=Barand link=topic=104530.msg417082#msg417082 date=1155766224]
But what's the point of storing a date whose sole purpose is to look pretty. Dates should be stored for functionality. The format can be chosen as you please when you query the table or output it.
[/quote]

yes, agreed. but my answer will be easy for beginners. it is just inserting and showing a date. ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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