Page 1 of 1

PHP/SQL error[RESOLVED]

Posted: Fri Jan 06, 2006 9:20 am
by nawhaley
I'm running MS SQL server and trying to run the following code and it keeps telling me theres an error near the keyword "WHERE".

Code: Select all

$link= odbc_connect("ImmagetechQuiz","Trainee","tra1ning");

$udate =date('m/d/Y h:i:s');
$user = "nawhaley";
print($udate);
$datquery ="INSERT INTO tblStudents (TGPDate) VALUES ('$udate') WHERE Username ='$user'";
$insertdate = odbc_exec($link,$datquery);
I'm really not sure where my error is in this. TGPDate is a datetime format on my SQL server. Is the format wrong, can you not use a WHERE conditional in an insert statement or what?

Posted: Fri Jan 06, 2006 9:28 am
by nawhaley
*sigh*..nevermind not enough caffine for Nick this morning apparently it should of dawned on me to use a UPDATE statement