LostKID Posted September 14, 2009 Share Posted September 14, 2009 i dont know what the hell im doing, im kinda going along with the flow.. i know a little php and have been doing the best i can.. okay let me paint the picture. The site is for a small friendly clan site, somewhere to post images, status updates, house tournements and so forth. im pulling information from xbox.com for any account someone signs up very simple stuff. My index page consists of a session then header image then an if statement, ie if logged in show Control panel, if not show login form. this all works a treat. but the only problem im having is that when the control panel.php is included getting information from my database seems to be a problem. and i get this error: Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 the coding on index.php: <? session_start(); // CONNECT TO THE DATABASE mysql_connect ("localhost", "xxx", "xxx") or die ('Error: ' . mysql_error()); mysql_select_db ("xxx"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>HSK.</title> <style type="text/css"> <!-- body,td,th { font-family: Helvetica, Arial , sans-serif; color: #FFFFFF; font-size: 12px; } body { background-color: #2d2d2d; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } #header{ width: 100%; height: 178px; background: url(images/header_bg.gif) repeat-x; } #headerInsert{ width: 1000px; height: 178px; background: url(images/header.gif) no-repeat center; } #columns{ width: 1000px; height:auto; } #column1{ float:left; width: 480px; margin: 10px; } #column2{ float:left; width: 480px; margin: 10px; } a{ color: #91FF3A; text-decoration:none; } a:hover{ color: #FFFFFF; text-decoration:none; } --> </style> </head> <body> <div align="center"> <div id="header"><div id="headerInsert"></div></div> <? if( @$_SESSION['auth'] != "yes" ){ include("login.php"); } else{ include("cp.php"); } ?> <div id="columns"> <div id="column1"></div> <div id="column2"> <table width="458" border="0" cellspacing="3" cellpadding="10"> <tr> <td bgcolor="#2D2D2D">New Users Signed up: </td> </tr> </table> <? $query2 = "SELECT * FROM user ORDER BY date DESC"; $results2 = mysql_query($query2) or die ("Could not execute query"); while ($row2 = mysql_fetch_array($results2)){ extract($row2);?> <table width="458" height="46" border="0" cellpadding="10" cellspacing="0" background="images/box_new_small.gif"> <tr> <td width="20" align="center" valign="middle"><? echo"<img src='http://avatar.xboxlive.com/avatar/$gamert/avatarpic-l.png' width='20' height='20' alt='' />" ?></td> <td width="460" align="left" valign="middle"><? echo"<a href='page.php?id=$id'> $username </a>" ?> is now a member of the HSK. </td> </tr> </table> <? }?> </div> </div> </div> </body> </html> and so far for my CP page is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>login</title> <style type="text/css"> <!-- body,td,th { font-family: Helvetica, Arial, sans-serif; color: #FFFFFF; } body { background-color: #323232; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } #login{ width: 100%; height: 50px; border-bottom: solid 1px #555555; background: url(images/login_box.gif) center no-repeat; } #loginform{ width: 939px; height: 17px; position:relative; top: 12px; left: 0px; } a{ color: #90FF38; text-decoration: none; } .textInput { background-color:#333333; border:solid 1px #9A9A9A; color: #FFFFFF; height: 17px; padding-left: 5px; margin-left: 5px; margin-right: 5px; } .textInput2 { background-color:#333333; border:solid 1px #9A9A9A; color: #33FF00; height: 17px; text-align: center; margin-left: 5px; margin-right: 5px; } .submitForm{ background: url(images/button.gif) no-repeat center; width: 60px; height: 22px; color:#FFFFFF; margin-left: 4px; margin-top: 4px; border:none; } #label{ background: url(images/label.gif); height: 22px; width: 70px; color:#FFFFFF; } --> </style> </head> <body> <div align="center"> <div id="login"> <div id="loginform"> <form id="form1" name="form1" method="post" action="login_process.php"> <label>Welcome:</label> <? echo"<img src='http://avatar.xboxlive.com/avatar/$gamert/avatarpic-l.png' width='20' height='20' alt='' />" ?> <? echo"<a href='page.php?id=$id'> $username </a>" ?> <input type="button" name="Submit2" value="Logout" class="submitForm" onclick="parent.location='logout_process.php'"/> </form> </div> </div> </div> </body> </html> how do i call my variables from an include statement and also not get the sessions error? and to test it in action. http://xbox.brokenbox.co.uk Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/ Share on other sites More sharing options...
AviNahum Posted September 14, 2009 Share Posted September 14, 2009 i think the global variables are disabled in your server, you have to talk to your admin server and ask him to enable global vars option... Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917931 Share on other sites More sharing options...
LostKID Posted September 14, 2009 Author Share Posted September 14, 2009 okay great now im being a bit noobie. but i when in the CP i have it to display the details but i cant remember how to call a session variable for reference to who your logged in as.. this is what i need the session variable is this: $_SESSION['username'] = $username; and i want it to get your information in the CP like this: $query2 = "SELECT * FROM user WHERE=$_SESSION['username'] "; or something like that is that how its done or is there a better method? Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917932 Share on other sites More sharing options...
AviNahum Posted September 14, 2009 Share Posted September 14, 2009 yes, you can use this method, easy and simple... Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917933 Share on other sites More sharing options...
LostKID Posted September 14, 2009 Author Share Posted September 14, 2009 yes, you can use this method, easy and simple... is the coding right though because i just gave that a shot.. i dunno if it will work xD haha.. ill give it a go Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917934 Share on other sites More sharing options...
AviNahum Posted September 14, 2009 Share Posted September 14, 2009 if you got more questions, ask away... Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917936 Share on other sites More sharing options...
PFMaBiSmAd Posted September 14, 2009 Share Posted September 14, 2009 DON'T enable register_globals for any reason. The were turned off by default over seven years ago because they allow a hacker to set your session variables. They have also completely been removed in php6. Like the error message states, this is a BUG in php that is due to an error in the way that register_globals was implemented (when register_globals are off, if you create a variable/session variable with a null value and there is a same name variable/session variable, you get that error.) Set either one or both of the settings that are mentioned in the error to OFF. Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917937 Share on other sites More sharing options...
LostKID Posted September 14, 2009 Author Share Posted September 14, 2009 DON'T enable register_globals for any reason. The were turned off by default over seven years ago because they allow a hacker to set your session variables. They have also completely been removed in php6. Like the error message states, this is a BUG in php that is due to an error in the way that register_globals was implemented (when register_globals are off, if you create a variable/session variable with a null value and there is a same name variable/session variable, you get that error.) Set either one or both of the settings that are mentioned in the error to OFF. okay do i ask my hosting provider to do this or is this something i can do my end? if so.. how? Also i still cant quite get the session variable.. im close i can feel it but im missing something this is what im trying: $query2 = "SELECT * FROM user WHERE={$_SESSION['username']}"; but its comes out wrong. should i try it without the = ? Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917942 Share on other sites More sharing options...
AviNahum Posted September 14, 2009 Share Posted September 14, 2009 $query2 = "SELECT * FROM user WHERE username='{$_SESSION['username']}'"; change the username to the name of the colume in your DB Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917944 Share on other sites More sharing options...
LostKID Posted September 14, 2009 Author Share Posted September 14, 2009 $query2 = "SELECT * FROM user WHERE username='{$_SESSION['username']}'"; change the username to the name of the colume in your DB Wooo awesome, thank you so much yeaaay its nice to see it finally coming together, i have never built anything as big as what i want this to turn out to be, my clan friends will be so happy to see it done too. usually im just moving vars in an out of database for very simple simple stuff.. i hope this will be much bigger thank you again Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917945 Share on other sites More sharing options...
LostKID Posted September 14, 2009 Author Share Posted September 14, 2009 Okay so i tried a couple of things and didnt get anywhere. first i created my "php.ini" file and uploaded it to /MY its had contents of: session.bug_compat_42 = 0ff session.bug_compat_warn = Off display_errors = Off display_startup_errors = Off nothing changed i still got the error.. so then i tried to change the same shared name between variable and session variable FROM: session_start(); $_SESSION['auth'] = "yes"; $_SESSION[username] = $username; TO: session_start(); $_SESSION['auth'] = "yes"; $_SESSION['user'] = $username; WITH THE RECIEVING END BEING: $query2 = "SELECT * FROM user WHERE username='{$_SESSION['user']}'"; i still get the same error..im totally stuck and i cant find much documentation that i understand clearly Quote Link to comment https://forums.phpfreaks.com/topic/174136-session-error-in-include/#findComment-917965 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.