Hi!
I am trying to enter times and dates into a MySql database so that they can be recalled and displayed by each entry on a gossip page on my website (www.rupstar.co.uk). I have made the table in the database but i think i'm using the wrong function to garner the time and date and put it into the database.
Thanks in advance for your help - code follows....
rupertbj
<?php
if ( isset( $name ) and isset( $gossip ) )
{
$db = "gossip";
$link = mysql_connect( "localhost:/users/rupertbj/domains/rupstar.co.uk/sql/mysql.sock", "root" );
if ( !$link ) die( "Couldn't connect to MySQL" );
if (!(mysql_select_db( $db, $link )))
{
$query="CREATE database gossip";
mysql_query( $query, $link );
mysql_select_db("gossip",$link);
$query="CREATE TABLE gossipTable (
id int(11) NOT NULL auto_increment,
date_time datetime NOT NULL,
name varchar(50) NOT NULL,
user varchar(30) NOT NULL,
gossip varchar(200) NOT NULL,
PRIMARY KEY (id)
)";
mysql_query( $query, $link );
}
$date_time = "SELECT CURTIME(), CURDATE()";
mysql_select_db( $db, $link ) or die( "Couldn't open $db: ".mysql_error() );
$sql = "INSERT INTO gossipTable VALUES ( '', '$date_time', '$name', '$user', '$gossip' )";
$result = mysql_query( $sql, $link );
mysql_close( $link );
}
?>