Mudsaf Posted July 2, 2013 Share Posted July 2, 2013 Alright so now i have problem with my code. Ill explain bit Index.php This basically receives data by jQuery get method, lets say from file name "data.php?cat=potato" and in flight i may change the receive get to data.php?cat=carrot Data.php //Alright so here i have the problem. I'm starting the sessions like this.session_start();$cat = $_GET['category'];$query_get_data_latest_date = "SELECT * FROM ms_date WHERE category = '$cat' ORDER BY DESC LIMIT 0, 1";$result blablabla... you know it$row_date['date'] //This returns to latest date value (Correctly)$_SESSION['date'] = $row_date['date']; //Returns older value gained before changing WHERE at query. So basically $_SESSION['date'] sticks to first value created by session and will not update. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted July 2, 2013 Share Posted July 2, 2013 (edited) Alright so now i have problem with my code. Ill explain bit Index.php This basically receives data by jQuery get method, lets say from file name "data.php?cat=potato" and in flight i may change the receive get to data.php?cat=carrot Data.php //Alright so here i have the problem. I'm starting the sessions like this.session_start();$cat = $_GET['category'];$query_get_data_latest_date = "SELECT * FROM ms_date WHERE category = '$cat' ORDER BY DESC LIMIT 0, 1";$result blablabla... you know it$row_date['date'] //This returns to latest date value (Correctly)$_SESSION['date'] = $row_date['date']; //Returns older value gained before changing WHERE at query. So basically $_SESSION['date'] sticks to first value created by session and will not update. do you have a session_start(); in the index.php? because you didnt mention if you did or didnt, also do you have a query which update the data? Edited July 2, 2013 by DDs1 Link to comment Share on other sites More sharing options...
Mudsaf Posted July 2, 2013 Author Share Posted July 2, 2013 Yes i have session in index.php Also i have jquery script that updates the data with get method every 2s. This function will be runned in every 2s the cat variable has been created and can be changed with jquery. function showContent() { $.get('data.php?category=' + cat function(data) { if (data != "NOUPDATE") { $('#mydiv').html(data); } }); } Link to comment Share on other sites More sharing options...
divinedesigns1 Posted July 2, 2013 Share Posted July 2, 2013 Yes i have session in index.php Also i have jquery script that updates the data with get method every 2s. This function will be runned in every 2s the cat variable has been created and can be changed with jquery. function showContent() { $.get('data.php?category=' + cat function(data) { if (data != "NOUPDATE") { $('#mydiv').html(data); } }); } what about defining the session on the index page? Link to comment Share on other sites More sharing options...
Mudsaf Posted July 2, 2013 Author Share Posted July 2, 2013 (edited) The session "$_SESSION['date']" isn't created on index.php page, its removed if it exists. Edited July 2, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
divinedesigns1 Posted July 2, 2013 Share Posted July 2, 2013 The session "$_SESSION['date']" isn't created on index.php page, its removed if it exists. i believe it need to be define before it can be removed Link to comment Share on other sites More sharing options...
justsomeguy Posted July 2, 2013 Share Posted July 2, 2013 I can't tell what the specific problem is, but what you described in the first post doesn't happen. If you set a variable then it's going to have the value that you set to it, it's not going to ignore that and use a different value. I can't tell what is actually happening though from the code you've shown. Maybe the browser is caching results, you can avoid that by adding a unique value to the querystring. Link to comment Share on other sites More sharing options...
Mudsaf Posted July 3, 2013 Author Share Posted July 3, 2013 (edited) Hah fixed it by own logic. Actually this wasn't my code what i linked but it was very similar. Thanks for all who tried to help :> Edited July 3, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now