Can someone tell me why I am unable to update a table in mysql using php with session data.
First of all, I have done some reading around daniweb and Im not sure if i should be using UPDATE or INSERT to update the table.
I have session_start(); at the top of my page and I have echo'd out the session data as below, so I know the data is correct.
<?php echo $_SESSION['SESS_IMG1'];?><br>
<?php echo $_SESSION['SESS_COUNTRY'];?><br>
<?php echo $_SESSION['SESS_CITY'];?><br>
Im trying to update a mysql table every time a page loads with the session data.
at first I tried the following using the session data
$sql = "INSERT INTO viewed id='', uid='$urlid', usecurecode='".$_SESSION['SESS_SECURE_CODE']."', ulogin='".$_SESSION['SESS_LOGIN']."', uimg='".$_SESSION['SESS_IMG1']."', ucountry='".$_SESSION['SESS_COUNTRY']."', ucity='".$_SESSION['SESS_CITY']."', uage='".$_SESSION['SESS_AGE']."', vdate='now()'";
$result = mysql_query($sql) or die(mysql_error());
echo "Thank you! Information updated.";
I then tried using the session variables
mysql_query("INSERT INTO viewed (uid,usecurecode,ulogin,uimg,ucountry,ucity,uage,vdate)
VALUES ('$urlid','$_SESSION[$securecode]', '$_SESSION[$login]', '$_SESSION[$img1]', '$_SESSION[$country]', '$_SESSION[$city]', '$_SESSION[$age], 'now()')")
or die("couldn't add new user");
and I have also tried
$sql = "UPDATE viewed SET uid='$urlid', usecurecode='".$_SESSION['SESS_SECURE_CODE']."', ulogin='".$_SESSION['SESS_LOGIN']."', uimg='".$_SESSION['SESS_IMG1']."', ucountry='".$_SESSION['SESS_COUNTRY']."', ucity='".$_SESSION['SESS_CITY']."', uage='".$_SESSION['SESS_AGE']."', vdate='now()'";
$result = mysql_query($sql) or die(mysql_error());
echo "Thank you! Information updated.";
With trying the above three, I am still unable to update the table viewed with the session data, and im a bit stuck now as how i update