For the life of me, i've been working with this for so long, i've done many updates that have worked, but for some reason, it won't work with this bit of code:
If anyone can see anything wrong with it, please help me out. I'm a little stuck:
if (isset($_POST['membership'])){
$accTypeID = getAccTypeID($db, $_POST['membership']);
$res = pg_query("SELECT * FROM accounts where username='" .$_SESSION['username']. "'");
$rec = pg_fetch_row($res);
if($res > 0){
pg_query("UPDATE accounts SET paymentdate ='" .date("Y-m-d"). "',
accounttype_id=$accTypeID
WHERE username='" .$_SESSION['username']. "'");
$p->addContent('Purchasing has succeeded.');
}
}
I run this with my website and it says it works, but when i check my database, nothing has been updated and my console produces this error:
pg_query(): Query failed: ERROR: syntax error at or near "WHERE"\nLINE 3: WHERE username='anuj'