how to set a field in mysql when loading a page using PHP -
i need set variable in person's profile when hit page, if refresh or try , click link again, page not load video. can of done, can't seem find reliable way set 'video' field 1 when page loads. default variable 0 every user , when load page, should set 'video' field 1.
i tried getting error:
$video = "query_to_find_video_field"; if ($video==0) { $sql = "update profile set video=1 id='.$user->id"; $query = mysql_query($sql); }
so can see, execute sql query if field not set. thanks!
stop using mysql
. has been deprecated php. i'll recommend learn pdo
or bind param
.
try now:
$video = "query_to_find_video_field"; if ($video==0) { $sql = "update profile set video=1 id='$user->id'"; $query = mysql_query($sql); }
Comments
Post a Comment