qmqmqm Posted February 13, 2009 Share Posted February 13, 2009 Hi I am new to php and this forum. I have this following piece of code in a php file, which I put inside the /xampp/htdocs folder. session_start(); $ses_startvar = "started"; session_register("ses_startvar"); //code after the HTML form if (isset($posted)) { if (strlen($_COOKIE[phpSESSID]) == 32) { echo "Session ID is being maintained in a cookie<br> and is " . $_COOKIE[phpSESSID]; } else { echo "Session ID is being maintained in a querystring<br> and is " . $GLOBALS[phpSESSID]; } The php file loads fine. But when I click on the button, it should show me the cookie id. However when I click on the button nothing is echoed. Does anyone know why? Thanks, Tom Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/ Share on other sites More sharing options...
The Little Guy Posted February 13, 2009 Share Posted February 13, 2009 change: $_COOKIE[phpSESSID]; to: $_COOKIE['PHPSESSID']; Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/#findComment-761634 Share on other sites More sharing options...
qmqmqm Posted February 13, 2009 Author Share Posted February 13, 2009 Thank you The Little Guy. Unfortunately that does not solve the problem. In fact I am having some trouble with other php code as well, such as: $my_var = $form_var; echo "The value of \$my_var is $my_var <br>"; if (is_numeric($my_var)) { $my_var = $my_var * 1; } if ($my_var == "true" or $my_var == "false" or $my_var == "yes" or $my_var == "no") { settype($my_var, "boolean"); } echo "The data type of \$my_var is " . gettype($my_var); Nothing would be echoed on the webpage when I click on the button. Anybody knows why? Thanks. Tom Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/#findComment-761641 Share on other sites More sharing options...
PFMaBiSmAd Posted February 13, 2009 Share Posted February 13, 2009 The code you posted relies on a feature (register_globals) that was turned off almost 7 years ago in php4.2 and has been removed in php6. You either need to fix the code or find more up to date code that does what you want. Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/#findComment-761666 Share on other sites More sharing options...
qmqmqm Posted February 14, 2009 Author Share Posted February 14, 2009 I actually got these pieces of code from http://www.vtc.com/products/PHP-Project-Solutions-tutorials.htm which is published in 2004... Could there be other possibilities? Thanks, Tom Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/#findComment-761752 Share on other sites More sharing options...
PFMaBiSmAd Posted February 14, 2009 Share Posted February 14, 2009 No mistake. The following problems exist in the code you posted - session_register("ses_startvar") does not work. Code needs to use the correct $_SESSION variable. $posted appears to be from a form field and does not work. Code needs to use the correct $_POST or $_GET variable. $_COOKIE[phpSESSID] is incorrect syntax. The correct syntax is $_COOKIE['PHPSESSID']. The first form does function but goes through a painfully slow defined constant search and error handling/recovery process before the actual array variable is referenced. In the last code you posted $form_var appears from a form, like the $posted variable and has the same problem. Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/#findComment-761764 Share on other sites More sharing options...
qmqmqm Posted February 14, 2009 Author Share Posted February 14, 2009 Thank you very much PFMaBiSmAd! Link to comment https://forums.phpfreaks.com/topic/145118-php-code-not-executing-in-xampphtdocs-folder/#findComment-762304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.