teeyaan Posted September 14, 2009 Share Posted September 14, 2009 my code works perfectly on localhost but when i uploaded it on hostgator, most of my app didn't work. i narrowed down the problem to this session variable. one of the session variable gets stored but the other doesn't. after a successful login my code travels to user_menu.php whose code is as follows -- <?php session_start(); if(!isset($_SESSION['userid'])) { header('location:../templates/login.php'); } if(isset($_SESSION['userid'])) { $x = $_SESSION['userid']; } echo "<html> ..... ...... <li><a href='../php/user_page.php?y=1&x=$x'>Main Category</a></li> in the above link, x=$x is the userid and y=1 is the number for the switch case. when the user clicks on the link for the 1st time the user_page.php gets loaded with the right template as per the y=1. see the user_page.php code below -- <?php session_start(); if(!isset($_SESSION['userid'])) { header('location:../templates/login.html'); } if(isset($_SESSION['userid'])) { $x = $_SESSION['userid']; } //get table id = y from menu & store in $num to execute the appropriate queries $num = $_GET['y']; if(!isset($_SESSION['num'])) { $_SESSION['num'] = $_GET['y']; } else{ //num is empty when form gets posted. So get num value from last stored SESSION['num'] if($num==""){ echo "<br>num empty but session_is_registered"; $num = $_SESSION['num']; echo "<br>NUM = " .$num; echo "<br>SESSION_NUM = " .$_SESSION['num']; } // $num not empty (while traversing menu) & the session['num'] holds last menu value // then store new num in the session['num'] else{ $_SESSION['num'] = $num;} } echo "<br>num = " .$num; echo "<br>session userid = " .$x; echo "<br>session table num = " .$_SESSION['num']; require_once('../classes/user_class.php'); include '../php/config.php'; include "../templates/user_menu.php"; $task1 = $_POST['add']; $task2 = $_POST['delete']; $fieldvalue = ucwords(strtolower($_POST['inputvalue'])); $fieldvalue = addslashes($fieldvalue); $option = $_POST['fields']; $option = mysql_real_escape_string($option); switch($num) { case 1: $table_name = 'main_categories'; $field = "cat_name"; $title = "Create/Delete Main Category"; $enter = "Enter New Main Category"; $see = "Main Categories"; break; ....................... ....................... } ....................... ....................... $query = "DELETE FROM $table_name WHERE $field = '$option' AND user_id = '$x'"; now when i try to delete from the dropdown box in the template, i get the following error. this error is a custom error from my class code --- DeleteFields() Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE = 'Trial1' AND user_id = '1'' at line 1 Generated by DELETE FROM WHERE = 'Trial1' AND user_id = '1' also i am getting the following echo --- num empty but session_is_registered NUM = SESSION_NUM = num = session userid = 1 session table num = so basically the $_SESSION['userid'] is set and comes through but $_SESSION['num'] doesn't get through when the form is posted i.e. when i press the delete button. also from the echo "num empty but session_is_registered", it does go in the else part that means the $_SESSION['num'] is set. i don't understand .. why? this code works perfectly on my localhost. i had upoaded this site on godaddy and it worked perfectly. but godaddy had no smtp so i had to switch my site to hostgator. now smtp works but the rest of my site doesn't because of the session problem. i can't access my switch case because of the $_SESSION['num'] problem. thank you Link to comment https://forums.phpfreaks.com/topic/174191-solved-one-session-variable-doesnt-get-stored/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 14, 2009 Share Posted September 14, 2009 What does a phpinfo(); statement show for the register_globals setting? If it is ON, you need to turn it off as soon as possible (assuming that none of your other code is dependent on it being on.) Link to comment https://forums.phpfreaks.com/topic/174191-solved-one-session-variable-doesnt-get-stored/#findComment-918280 Share on other sites More sharing options...
teeyaan Posted September 16, 2009 Author Share Posted September 16, 2009 sorry for replying late, but i wasn't able to test anything yesterday. today i opened the hostgator phpquickconfig setting and found that the register globals was on. so i turned it off. and it worked. now all my code is working properly except there's one issue. my scripts create charts/graphs. but i can't see any image being generated at my live site. my scripts worked perfectly on localhost. i had enabled extension=php_gd2.dll in my localhost. i can't find any way to enable the extension on hostgator. i asked tech support. they say that they have gd2 enabled and i don't need to enable anything. and that the .dll files are windows specific and that their servers are linux. somehow i am missing something here. i even removed "dl" from the disable_functions. but their enable_dl is "off" by default. do i need this for showing my image? i get the following error through firefox -- when i click the broken img link using right click and "view image" i get -- JpGraph Error Font file "/usr/X11R6/lib/X11/fonts/truetype/arialbd.ttf" is not readable or does not exist. thank you Link to comment https://forums.phpfreaks.com/topic/174191-solved-one-session-variable-doesnt-get-stored/#findComment-919432 Share on other sites More sharing options...
teeyaan Posted September 16, 2009 Author Share Posted September 16, 2009 never mind. i resolved the graph image problem. i hadn't saved the fonts on the server and i had to define the path to the fonts too. thank you for ur help. Link to comment https://forums.phpfreaks.com/topic/174191-solved-one-session-variable-doesnt-get-stored/#findComment-919479 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.