Jump to content

darp

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

darp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the fast reply. This works. Do I have it right or can I improve on it? $mysql = "UPDATE customer SET menulist = ' $menulist ', packlist = ' $packlist ' WHERE customer = '{$_SESSION['cid']}'"; mysql_query($mysql);
  2. In this link quotes withing a global session array are clarified http://www.phpfreaks.com/forums/mysql-help/%28solved%29-confused-as-to-what-quote-mark-to-use-in-a-query/ However I can't get $_SESSION['cid'] to work. Could someone explain to me why this works: $mysql = "UPDATE customer SET menulist = ' $menulist ', packlist = ' $packlist ' WHERE customer ='$_SESSION[cid]'"; mysql_query($mysql); Where as this does not. $mysql = "UPDATE customer SET menulist = ' $menulist ', packlist = ' $packlist ' WHERE customer =" . $_SESSION['cid']; mysql_query($mysql); What would the proper syntax/format be?
  3. Thanks, but I get conflicting information about this. I have been setting up an osCommerce store. Apparently the store does not require clients to have cookies enabled. Customers are tracked via sessions alone when they choose to have cookies disabled on their browser. A session id is written to mysql or a tmp directory and passed via the URL ( and some how hidden after the second click for security reasons ) . However, I have not been able to get this to work on my development machine. But you are saying that PHP sessions are dependent on cookies. Is that correct? There is no way to get sessions to work without cookies?
  4. If I have cookies disabled sessions do not work. PHP sessions are not supposed to be dependent on cookies are they? Here is a little script that shows the results. This was tested on Firefox, Konqueror and Opera. test_one.php <?php session_start(); echo session_id(); //RESULT: n27kncejcd4rt246037989eqn1jui6bj $_SESSION[id]=session_id(); echo "<br />"; var_dump($_SESSION[id]); //RESULT: string(32) "n27kncejcd4rt246037989eqn1jui6bj" ?> <br /> <a href="test_two.php" >Go to Test Two</a> //END OF test_one.php test_two.php <?php session_start(); echo session_id(); //RESULT: m9oh3l865ovrgvb2ue6tdlmnrflpevhb echo "<br />"; var_dump($_SESSION[id]); //RESULT: NULL ?> As you can see, in test_two.php the session_id is reset and $_SESSION[id] is NULL. When cookies are enabled everything has the same value, as it should. Why? Is this a PHP or a sever problem? The domain is localhost on my personal computer. Linux 2.6.31.12-0.2-default x86_64 Apache2.2 PHP 5.3
  5. I wrote a little test script as suggested. You can see the results. test.php <?php session_start(); echo session_id(); //n27kncejcd4rt246037989eqn1jui6bj $_SESSION[id]=session_id(); echo "<br />"; var_dump($_SESSION[id]); //string(32) "n27kncejcd4rt246037989eqn1jui6bj" ?> <br /> <a href="test_two.php" >Test</a> test_two.php <?php session_start(); echo session_id(); //m9oh3l865ovrgvb2ue6tdlmnrflpevhb echo "<br />"; var_dump($_SESSION[id]); //NULL ?> As you can see, in test_two.php the session_id is reset and $_SESSION[id] is killed. When cookies are enabled everything has the same value as it should. Why? Is this a PHP or a sever problem? The domain is localhost on my personal computer. Linux 2.6.31.12-0.2-default x86_64 Apache2.2 PHP 5.3 Tested on Firefox, Konqueror and Opera.
  6. How might I test sessions outside of the application? I have phpBB3 installed, but I believe that only functions with cookies enabled. When I have cookies enabled osCommerce retains $_SESSION and $_GET values. I have tested those with var_dump() and get the results I expect.
  7. I am setting up an e-commerce store, and it is misbehaving. I am using osCommerce which is supposed to work if a user has their browser cookies disabled. Without cookies the user is tracked by a session id that is passed on through the URL. However for some reason when I have the cookies disabled a new session is started with every click of the mouse at every link and every submit button. These sessions are stored in the store tmp directory or the mysql db depending on my configuration. They pile up fast while I get nowhere. I have had osCommerce people go over my configuration files ( over 100 have viewed my query ) and they seem to be fine. I downloaded a fresh, virgin catalog to make sure that the one I had had not been corrupted. I got the same results. So far nobody in the osCommerce forum can figure it out, and they seem to have run out of ideas. It seems the problem does not reside with the osCommerce code. It is the same code everyone else uses without a problem. So my question is, could this be a PHP issue? Is there any PHP configuration setting that I need to set in php.ini?. Is there a module I need? When cookies are enabled the sessions seem to work fine. The site domain is localhost. I am using; PHP 5.3, Apache 2.2, MySQL 5, Linux 2.6.31.12-0.2-default x86_64. Thank you in advance for any help.
  8. The code on the test page is this. I am trying to embed this in osCommerce, which is the source of the two 'require' files. The top one starts sessions and initializes the db connection. I am not sure of the purpose of the bottom file. <?php require('includes/application_top.php'); var_dump($_SESSION['menu_table']); echo "<br />"; var_dump($_SESSION['ingredient_table']); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> The contents of the require files is pretty esoteric. Could there be something in there? Why does it pass on the content of smaller files? Which one retains the content and which one is set to NULL depends on their order on the originating file.
  9. I have a couple of tables that I store in the following global arrays. $_SESSION['menu_table'] = $menu_table; $_SESSION['ingredients_tablet'] = $ingredients_table; The tables contain meal choices and the ingredients respectively. The meals and ingredients are selected from a mysql db. The tables can vary in size. Users can select up to 12 days of food and ingredients to be displayed. The biggest table is about 1500 lines of html long. The other table is much smaller. However, once 12 days has been selected the contents of the second array ( whichever one is furthest down the page, $_SESSION['ingredients_tablet'] in the example above.) is destroyed when it is passed on to the next file. The output of var_dump($_SESSION['ingredients_tablet']); is NULL. If I move the array up the file the other array becomes NULL. The file I am passing the arrays on to is a test file. There is nothing on it that would destroy the session. It is not a db issue. The variables in the tables are the same. The meal table is just a simplified version of the other. Both tables display flawlessly on the original file, and both arrays are set and output properly when they are checked with var_dump() on the originating file. The site is running on localhost right now. The memory limit is set to 256M in my php.ini. I don't know if that has anything to do with it. I am self taught so there are lots of holes in my php knowledge. Can anybody tell me what is going on? I was planning on giving users the option of selecting up to 14 days. Am I going to be limited to 11?
  10. While filling out a form I want the data to be stored in both metric and standard. The figures for the standard entries need only be accurate to the nearest quarter ounce. So the user input is grams and that figure is automatically divided by 28.349523125 to get the equivalent ounces. The problem is, entries like 100 grams are converted to 3.52739619496 ounces. What I would really like to see is 3.5 ounces and 92 grams converted to 3.25 ounces instead of 3.24520449936. The only values that I want to see are *.00 || *.25 || *.50 || *.75 Is this possible? P.S. The reason the original entry has to be in grams is because most of the original data is provided that way so doing the conversion the other way is not really an option.
  11. Is this normal behavior? PHP 5 Apache Server on a Linux box. Browser: Firefox. fileone.php <form action="filetwo.php" method="post" > <input type="radio" name="input" value="go" />GO <input type="radio" name="input" value="stop" />STOP <input type="submit" /> </form> ************************ filetwo.php <form action="filethree.php" > <?php session_start(); //go or stop $_SESSION["input"] = $_POST["input" ]; if ( $_SESSION["input" ] == 'go' ) { $input = "You may go!<br />"; } else { $input = "You have been stopped!<br />"; } echo $_SESSION["input"]; //the first time echos "go" or "stop", depending on user input. echo $input; //the first time echos "You may go!" or "You have been stopped!", depending on user input. ?> <input type="submit" /> </form> ************************ filethree.php <?php session_start(); echo $input; //the first time echos "go" or "stop", depending on user input. ?> //How did $input become a superglobal with the value of $_SESSION["input"]? ************************** Now, if I hit the browser back button filetwo.php gives these results: filetwo.php <form action="filethree.php" > <?php session_start(); //go or stop $_SESSION["input"] = $_POST["input" ]; if ( $_SESSION["input" ] == 'go' ) { $input = "You may go!<br />"; } else { $input = "You have been stopped!<br />"; } echo $_SESSION["input"]; // echos "You may go!" or "You have been stopped!", depending on user input. // When/How did the value of $_SESSION["input"] get changed? Shouldn't it remain "go" or "stop"? echo $input; //echos "You may go!" or "You have been stopped!", depending on user input. ?> <input type="submit" /> </form> ******************* Now, if I re-submit filethree.php gives me: filethree.php <?php session_start(); echo $input; //Now it echos "You may go!" or "You have been stopped!", depending on user input. ?> //How did $input become a superglobal with the value of $_SESSION["input"]? This only works this way if the key of $_SESSION is the same as the variable ( minus the $ symbol ). Is this normal? It doesn't seem right to me. I can't see how the variable in filethree.php becomes a superglobal or how the value of $_SESSION gets changed. Can anyone fill me in on what I should understand or know about $_SESSION and the back button?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.