|
-
Aug 3rd, 2010, 09:17 AM
#1
Thread Starter
Hyperactive Member
Remove Date() fucntion
Hi, I need to remove the date function on this script
PHP Code:
<?php
include("config.php");
$name = addSlashes($_POST['name']);
$email = $_POST['email'];
$comment = addSlashes($_POST['comment']);
$date_added = time();
$check = mysql_query("insert into comment(name,email,comment,date_added) values('$name','$email','$comment','$date_added')");
$date_added = date("l j F Y, g:i a",time());
if($check)
echo $date_added;
else
echo "0";
?>
and here is the ajax script for that
PHP Code:
$.ajax({
type: "POST",
url: "ajax_server.php",
data: "name="+name+"&email="+email+"&comment="+comment,
success: function(date_added){
if(date_added != 0)
{
structure = '<div class="comment_holder"><div id="photo"><img src="images/user.gif" width="60" height="70"><br>'+name+'</div><div id="comment_text"><div id="date_posted">'+date_added+'</div>'+comment+'</div></div>';
$(".no_comments").fadeOut("slow");
$("#ajax_response").prepend(structure);
$(".comment_table").find('textarea, input:text').each(function () {
$(this).val("");
});
}
else
alert("Unexpected error...!");
$("#loading").css("visibility","hidden");
}
});
}
});
I need to remove Date function on saving into my database.. I don't want to include system date value.. coz I change my data value to auto time_stamp on my phpmyadmin.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Aug 3rd, 2010, 10:12 AM
#2
Re: Remove Date() fucntion
well, just remove it then.
PHP Code:
<?php include("config.php"); $name = addSlashes($_POST['name']); $email = $_POST['email']; $comment = addSlashes($_POST['comment']); $check = mysql_query("insert into comment (name, email, comment) values('$name', '$email', '$comment')"); $date_added = date("l j F Y, g:i a"); if($check) echo $date_added; else echo 0; ?>
-
Aug 3rd, 2010, 10:21 AM
#3
Thread Starter
Hyperactive Member
Re: Remove Date() fucntion
@kows
I tried your codes but it give me this error
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for '-7.0/DST' instead in C:\xampp\htdocs\Comment\ajax_server.php on line 10
And that is pointing in this line
Code:
$date_added = date("l j F Y, g:i a");
And no data saved into database.
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Aug 3rd, 2010, 10:28 AM
#4
Re: Remove Date() fucntion
then go into your php.ini file and set a default timezone (date.timezone setting), or call the function date_default_timezone_set().
PHP Code:
date_default_timezone_set('America/Los_Angeles');
-
Aug 3rd, 2010, 10:48 AM
#5
Thread Starter
Hyperactive Member
Re: Remove Date() fucntion
still getting error 
Since Date is set in my phpmyadmin for automatic
I remove this part
Code:
$date_added = date("l j F Y, g:i a",time());
if($check)
echo $date_added;
else
echo "0";
When I submit a data to my database
I got this error
So I need to modify this part too
Code:
$.ajax({
type: "POST",
url: "ajax_server.php",
data: "name="+name+"&email="+email+"&comment="+comment,
success: function(date_added){
if(date_added != 0)
{
structure = '<div class="comment_holder"><div id="photo"><img src="images/user.gif" width="60" height="70"><br>'+name+'</div><div id="comment_text"><div id="date_posted">'+date_added+'</div>'+comment+'</div></div>';
$(".no_comments").fadeOut("slow");
$("#ajax_response").prepend(structure);
$(".comment_table").find('textarea, input:text').each(function () {
$(this).val("");
});
}
else
alert("Unexpected error...!");
$("#loading").css("visibility","hidden");
}
});
}
});
I think I need to remove this part too
Code:
function(date_added){
if(date_added != 0)
{
But I don't know the proper way..I am new in php and ajax ;(
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
-
Aug 3rd, 2010, 11:29 AM
#6
Re: Remove Date() fucntion
no, you don't need to remove any of the things that you removed. all of those things are needed because those are the key things that make this work. you don't seem to really know how AJAX works.
"Unexpected error..!" is a message that gets displayed because $check is false (meaning the query failed); this means there is a problem with your query, not anything else.
make a MySQL dump of your table (in phpMyAdmin, export your table's structure), and post it here.
-
Aug 4th, 2010, 08:29 PM
#7
Thread Starter
Hyperactive Member
Re: Remove Date() fucntion
its working now...thanks kows
VB 6.0 = "Self-Study" Then
vb.NET = "Self-Study" Then
C# = 'on going study.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|