Forum Moderators: coopster
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("mysql", $con);
[b]
$time=strtotime("now");
$ip=<?php echo $_SERVER['REMOTE_ADDR'];?>
$month=<?php echo date("n", $date);?>
[/b]
$sql="INSERT INTO phpnews_news (ip, time, month, year, subject, titletext, maintext, views, break, catid, trusted)
VALUES
('$_POST[ip]','$_POST[time]','$_POST[month]','$_POST[year]','$_POST[subject]','$_POST[titletext]','$_POST[maintext]','0','0','$_POST[catid]','0')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Article added on ";
echo date('l dS F Y h:i:s A');
echo " from ";
echo $_SERVER['REMOTE_ADDR'];
mysql_close($con)
?>
what is the proper way or syntax to write the above code in bold.
For $time, if you are wanting the current time stamp, do it in sql. EX:
$query = "INSERT INTO members (fname, mi, lname, suffix, gender, address, city, state, zipcode, phone, ip, time)
VALUES ( '$fname', '$mi', '$lname', '$suffix', '$gender', '$address', '$city', '$state', '$zipcode', '$phone', '$ip', now() )";