Foser Posted October 6, 2006 Share Posted October 6, 2006 Hello,I'm quite new to PHP, but I learn quickly. I did the tutorial on a simpel counter threw mysql and php, with no mistakes.Although Where can I find the count of people that came, i refreshed teh website, and went with another browser and didn't see any change in my mysql database no valuables changed. Where do I see how much people came?[code]<?phpsession_start();echo "Hello";$connection = mysql_connect ("localhost", "root", "*****" );if (!session_is_registered("counted")){ mysql_query ("UPDATE simplecount SET count=(count + 1) WHERE count_id=1"); WHERE count_id=1");session_register ("counted");}?>[/code]Thanks in advance to anyone which helped. Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/ Share on other sites More sharing options...
Hi I Am Timbo Posted October 6, 2006 Share Posted October 6, 2006 You see where it says if(!session_is_registered("counted"))That basically means if you haven't already been counted, then count you. If you have, don't count you.You would need a clean session to be counted again. Close your browser entirely and reopen the page, it should count you again. Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104828 Share on other sites More sharing options...
Foser Posted October 6, 2006 Author Share Posted October 6, 2006 I do realise that.I have done multiple sessions. But my question is. Where does it count the hits? I've looked eevryone in the database and stuff. but cant seem to find the variable which shows how many people (sessions) that have been recorded. Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104846 Share on other sites More sharing options...
HuggieBear Posted October 6, 2006 Share Posted October 6, 2006 It's updating the [color=red]count[/color] field in the [color=green]simplecount[/color] table.Also, the following is wrong:[code]<?phpmysql_query ("UPDATE simplecount SET count=(count + 1) WHERE count_id=1");WHERE count_id=1");?>[/code]It should just be as follows:[code]<?phpmysql_query ("UPDATE simplecount SET count=(count + 1) WHERE count_id=1");?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104849 Share on other sites More sharing options...
Foser Posted October 6, 2006 Author Share Posted October 6, 2006 OKay, this is what my code looks like now.[code]<?phpsession_start();echo "Hello";mysql_connect ("localhost", "root", "445589" );mysql_select_db("counter01");if (!session_is_registered("counted")){ mysql_query ("UPDATE simplecount SET count=(count + 1) WHERE count_id=1");session_register ("counted");}?>[/code]But now, I still cant see anything in my mysql database that seem sliek it counted something. i quit my browser wen ton page, changed browser and done lodes. But I cant see much that has changed in my database in variables..... Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104853 Share on other sites More sharing options...
HuggieBear Posted October 6, 2006 Share Posted October 6, 2006 Try this:[code]<?phpsession_start();echo "Hello";mysql_connect ("localhost", "root", "445589" );mysql_select_db("counter01");if ($_SESSION['counted'] != "true"){ $result = mysql_query("UPDATE simplecount SET count = (count + 1) WHERE count_id = 1") or die ("Unable to execute query: " . mysql_error()); $_SESSION['counted'] = $result;}?>[/code]The result of an update statement in mysql_query() is always either true or false, so why not use that as above. Also put a bit of error handling in there.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104864 Share on other sites More sharing options...
Foser Posted October 6, 2006 Author Share Posted October 6, 2006 Thanks huggie, its working fine no bugs.Although I still don't know where it's counting i don't see anything in the database. I don't see any variables changing.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104867 Share on other sites More sharing options...
HuggieBear Posted October 6, 2006 Share Posted October 6, 2006 OK, can you provide me the structure of your database then...Huggie Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104872 Share on other sites More sharing options...
Foser Posted October 6, 2006 Author Share Posted October 6, 2006 table : simplecount record: 0 Type: InnoDBcollation: latin1_swedish_ciseize 16 kbMy first row:Field: counttype: varchar(255)collation: latin1_swedish_ciattributes: ---Null: No My Second Row: Field: count_idtype: varchar(25)rest is same as first.its nothing fancy... Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-104994 Share on other sites More sharing options...
HuggieBear Posted October 6, 2006 Share Posted October 6, 2006 The table should have two columns and one row...Column: count_idType: int(6)Value: 1Column: counttype: int(6)Value: 0That should do the trick.Huggie Quote Link to comment https://forums.phpfreaks.com/topic/23154-help-with-simple-mistake/#findComment-105015 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.