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;
?>
Re: Remove Date() fucntion
@kows
I tried your codes but it give me this error
Quote:
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.
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');
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
Quote:
"Unexpected 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 ;(
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.
Re: Remove Date() fucntion
its working now...thanks kows