Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi im newbie in this forum and im also new when it comes to working with mysql...well right now i am working with a senior project together with my groupmates..we are working with an ordering and inventory system using php and mysql..we encountered one problem..we created a customer table..it contains customer info and other details about the customer and at the end of the table we added two fields. we named it DateCreated and DateModified. we used datetime as the data type..our problem is that the database doesn't recognize the NOW()..we have executed the query that we made through heidi sql. here is our code..everything is working well..if remove the two 'DateCreated' and 'DateModified'..the query is working well but the two remains at 0000-00-00 00:00:00.
here's the create table query that we used..
[syntax="sql"]CREATE TABLE `tblcustomer` (
`Customerno` int(11) NOT NULL auto_increment,
`FirstName` varchar(30) NOT NULL default '',
`LastName` varchar(30) NOT NULL default '',
`Address` varchar(50) NOT NULL default '',
`Contactno` varchar(20) NOT NULL default '',
`Email` varchar(50) NOT NULL default '',
`ZipCode` varchar(12) NOT NULL default '',
`Province` varchar(50) NOT NULL default '',
`DateCreated` datetime NOT NULL default '0000-00-00 00:00:00',
`DateModified` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`Customerno`),
UNIQUE KEY `Customerno` (`Customerno`)
) TYPE=MyISAM;this our code in adding the customer...[/syntax]
Code: Select all
<?
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "";
$DBName = "thesis";
$table = "tblcustomer";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
$BDay = $_POST['BDay'];
$Address = $_POST['Address'];
$Address2 = $_POST['Address2'];
$Age = $_POST['Age'];
$Gender = $_POST['Gender'];
$Contactno = $_POST['Contactno'];
$Email = $_POST['Email'];
$ZipCode = $_POST['ZipCode'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Busname = $_POST['Busname'];
$Busadd = $_POST['Busadd'];
$Bustel = $_POST['Bustel'];
$sqlquery = "INSERT INTO `tblcustomer`(`FirstName`, `LastName`, `Address`, `Address2`, `Age`, `Gender`, `BDay`, `Contactno`, `Email`, `ZipCode`, `Username`, `Password`, `Busname`, `Busadd`, `Bustel`, 'DateCreated', 'DateModified')
VALUES('$FirstName','$LastName','$Address','$Address2','$Age','$Gender','$BDay','$Contactno','$Email','$ZipCode','$Username','$Password','$Busname','$Busadd','$Bustel',NOW(),NOW())";
$results = mysql_query($sqlquery);
mysql_close();
?>right now what we are doing is that we working on the modules first..we are trying to make these modules function. we are working with the add customer..guys maybe you can help us out with our problem..we are new to these things and would appreciate all your help. thank you very much
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]