everlifefree Posted January 15, 2008 Share Posted January 15, 2008 Ok I have this code that works great where it is now but when I try to add it to other pages it won't work. Here is the original code: /* Update video data; views count */ if (!isset($_SESSION["video_view"]) or (isset($_SESSION["video_view"]) and $_SESSION["video_view"] != $row["id"])) { myQ("UPDATE `[x]video` SET `views` = `views` + '1' WHERE `id`='{$row["id"]}'"); $_SESSION["video_view"] = $row["id"]; And here's my changed code: /* Update user data; views count */ if (!isset($_SESSION["profile_view"]) or (isset($_SESSION["profile_view"]) and $_SESSION["profile_view"] != $row["id"])) { myQ("UPDATE `[x]users` SET `views` = `views` + '1' WHERE `id`='{$row["id"]}'"); $_SESSION["profile_view"] = $row["id"]; Anybody know why it isn't working?? My guess is something to do with the sessions but I don't know what to change. Please Help... Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/ Share on other sites More sharing options...
teng84 Posted January 15, 2008 Share Posted January 15, 2008 can you tell us what do you mean by it wont work? Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-439491 Share on other sites More sharing options...
everlifefree Posted January 15, 2008 Author Share Posted January 15, 2008 when I visit the page everything runs fine but it doesn't add any pageviews to my database like it is supposed to so pretty much I have code sitting there doing nothing, when I need to be add page views Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-439496 Share on other sites More sharing options...
teng84 Posted January 15, 2008 Share Posted January 15, 2008 if (!isset($_SESSION["profile_view"]) or (isset($_SESSION["profile_view"]) and $_SESSION["profile_view"] != $row["id"])) { myQ("UPDATE `users` SET `views` = `views` + 1 WHERE `id`='{$row["id"]}'"); $_SESSION["profile_view"] = $row["id"]; try ... Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-439500 Share on other sites More sharing options...
everlifefree Posted January 15, 2008 Author Share Posted January 15, 2008 That just created this error: Parse error: syntax error, unexpected $end in /home/sites/spadespace.com/public_html/modules/users/profile.php on line 1171 Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-439514 Share on other sites More sharing options...
teng84 Posted January 15, 2008 Share Posted January 15, 2008 what is in line 1171? Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-439520 Share on other sites More sharing options...
everlifefree Posted January 15, 2008 Author Share Posted January 15, 2008 $_SESSION["profile_view"] = $row["id"]; it went away when I added a } after it but it still doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-439541 Share on other sites More sharing options...
everlifefree Posted January 17, 2008 Author Share Posted January 17, 2008 Still need help nothings worked yet! Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441502 Share on other sites More sharing options...
teng84 Posted January 17, 2008 Share Posted January 17, 2008 on your function myQ can can you put na sql error reporting so we know what causes this error? or to debug inside your if statement echo your name so you know if your condition is really satisfied to perform your query Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441507 Share on other sites More sharing options...
everlifefree Posted January 17, 2008 Author Share Posted January 17, 2008 sorry what? Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441577 Share on other sites More sharing options...
teng84 Posted January 17, 2008 Share Posted January 17, 2008 instead of using the typical way of querying you use a function which is myQ may be you need to post that function here.. or inside your if statement echo anything so you know if your condition is being satisfied.. or on your function myQ find there the function mysql_query and add a mysql error reporting in the end of that line Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441581 Share on other sites More sharing options...
everlifefree Posted January 17, 2008 Author Share Posted January 17, 2008 Whats the code look like with that? Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441582 Share on other sites More sharing options...
teng84 Posted January 17, 2008 Share Posted January 17, 2008 lol you use a code that is not familiar to you.. maybe there's is a page included on that page that contains that function that should look like this function myQ($etc..){ //stuff here } Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441590 Share on other sites More sharing options...
everlifefree Posted January 17, 2008 Author Share Posted January 17, 2008 Ya, it was a developer script I installed and I'm try to change a few things Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441613 Share on other sites More sharing options...
everlifefree Posted January 17, 2008 Author Share Posted January 17, 2008 So your sure it's not just the sessions or its missing some of the code that would cause it to work. Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441615 Share on other sites More sharing options...
teng84 Posted January 17, 2008 Share Posted January 17, 2008 right now im not sure of anything. like i said we have to know the problem one by one first check your ifs if it works then your query.. ok if (!isset($_SESSION["profile_view"]) or (isset($_SESSION["profile_view"]) and $_SESSION["profile_view"] != $row["id"])) { echo 'hi this is teng'; myQ("UPDATE `users` SET `views` = `views` + 1 WHERE `id`='{$row["id"]}'"); $_SESSION["profile_view"] = $row["id"]; //missing code here if it echo the added line i put then its your query or your function that has a problem.. its pretty hard to guess you need to look on all side of your code Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-441622 Share on other sites More sharing options...
everlifefree Posted January 18, 2008 Author Share Posted January 18, 2008 I add your code and these are the errors that showed but these all showed before I started try to add all this. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sites/spadespace.com/public_html/system/functions/database/mysql.fnc.php on line 37 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sites/spadespace.com/public_html/system/functions/database/mysql.fnc.php on line 37 Notice: Undefined variable: contactsCount in /home/sites/spadespace.com/public_html/modules/users/profile.php on line 625 Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-442356 Share on other sites More sharing options...
teng84 Posted January 18, 2008 Share Posted January 18, 2008 that is not suppose to be the error of the code i gave because you don't fetch the result of update query where is line 37 in mysql.fnc.php and this Undefined variable: contactsCount on line 625 Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-442360 Share on other sites More sharing options...
everlifefree Posted January 18, 2008 Author Share Posted January 18, 2008 Still Need Help Quote Link to comment https://forums.phpfreaks.com/topic/86060-view-count-issue/#findComment-442565 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.