Joe Bills Joe Bills - 7 months ago 25
SQL Question

Profile View Update

I am trying to create a query which will update each person's profile views when a member accesses their profile. For some reason it does not update, I am sure it would have worked. Here is my lines:

<?php
$name = $_REQUEST['username'];
$profile = mysql_query("SELECT * FROM users WHERE user_name='$name'");
$uprofile = mysql_fetch_assoc($profile);

$username = $uprofile['user_name'];
$profilev = $uprofile['profile_views'];

mysql_query("UPDATE users SET profile_views +1 WHERE user_name='$name'");

?>


So, On my profile, It displays their username successfully, and it displays the default value of the database for profile_views which ofcourse, is
0
. so it is reading correctly, I am just having issues updating the users profile_views.

Answer

You have a mistake try

"UPDATE users 
 SET profile_views = profile_views  +1 
 WHERE user_name='$name'"