WebStyles Posted February 23, 2014 Share Posted February 23, 2014 wanna post the code for the main page? Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470139 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 main page: <?php error_reporting(E_ALL); session_start(); include("safe.php"); include("functions.php"); if(!isset($_SESSION['uid'])){ echo "Please go back and log in"; }else{ ?> <html> <meta charset="utf-8"> <title>Aurora</title> <link href="../style.css" rel="stylesheet" type="text/css"> </head> <body> <div style="position: relative" id="wrapper"> <!-- Menu Panel End --> <div id="mainheader"> </div> <?php include("statbar.php"); ?> <div id="sidebar"> <h3>Navigation</h3> <?php include("ingamenav.php");?> <h3>Account</h3> <div id="login" class="login"><center><form action="/Template/login.php" method="post"> Username:<br> <input name="username" type="text" class="tb1" maxlength="24"><br /> Password:<br> <input class ="tb1" type="password" name="password"/><br /> <input class="tb1" type="submit" name="login" value="Login"/> </form></center> <p><a href="#">Forgot Password</a><br> <a href="#">Register</a><br></p> </div> <h3></h3> <div class="banners"> Reserved for banners </div> </div> <div id="content_area"> <h1>Command Center<span></span></h1> <p>The Command Center gives you get a detailed inventory of your resources, military, and the status of your outpost's population.</p> <div style="position: relative"> <table id="stattable" width="600"> <tr> <th BGCOLOR="#660000" colspan="2" scope="row">Resources</th> </tr> <tr> <th scope="row">Credits</th> <th scope="row"><?php echo $user['credits']; ?>#</th> </tr> <tr> <th scope="row">Networth</th> <th scope="row"><?php echo $user['networth']; ?>#</th> </tr> <tr> <th scope="row">Turns</th> <th scope="row"><?php echo $user['turns']; ?>#</th> </tr> <tr> <th scope="row">Energy</th> <th scope="row"><?php echo $user['energy']; ?>#</th> </tr> <tr> <th scope="row">Biozene Gas</th> <th scope="row"><?php echo $user['gas']; ?>#</th> </tr> <tr> <th scope="row">Ore</th> <th scope="row"><?php echo $user['ore']; ?>#</th> </tr> <tr> <th scope="row">Food</th> <th scope="row"><?php echo $user['food']; ?>#</th> </tr> <tr> <th width="294" scope="row">Land</th> <th width="294" scope="row"><?php echo $user['land']; ?>#</th> </tr> <tr> <th BGCOLOR="#660000" colspan="2" scope="row">Your Populous</th> </tr> <tr> <th scope="row">Population</th> <th scope="row"><?php echo $user['population']; ?>#</th> </tr> <tr> <th scope="row">Loyalty</th> <th scope="row"><?php echo $user['loyalty']; ?>#</th> </tr> <tr> <th BGCOLOR="#660000" colspan="2" scope="row">Your Military</th> </tr> <tr> <th scope="row">Trainees</th> <th scope="row"><?php echo $user['population']; ?>#</th> </tr> <tr> <th scope="row">Prisoners of War</th> <th scope="row"><?php echo $user['prisoner']; ?>#</th> </tr> <tr> <th scope="row">Juggernauts</th> <th scope="row"><?php echo $user['juggernaut']; ?>#</th> </tr> <tr> <th scope="row">Infantry</th> <th scope="row"><?php echo $user['infantry']; ?>#</th> </tr> <tr> <th scope="row">Marauders</th> <th scope="row"><?php echo $user['marauder']; ?>#</th> </tr> <tr> <th scope="row">Recon Squads</th> <th scope="row"><?php echo $user['reconsq']; ?>#</th> </tr> <tr> <th scope="row">Terminator</th> <th scope="row"><?php echo $user['terminator']; ?>#</th> </tr> <tr> <th scope="row">Destroyers</th> <th scope="row"><?php echo $user['destroyer']; ?>#</th> </tr> </table> </div> <!--Table of Contents End --> </div><!--Content Area End --> <div id="footer"> <p>All Rights Reserved © 2014 <a href="#">Aurora Game</a></p> </div><!--Footer End --> </div><!-- Wrapper End --> </body> </html> } <?php } The errors Im getting are: [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: turns in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 14 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: gas in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 15 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: energy in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 16 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: ore in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 17 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: food in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 18 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: land in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 19 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: population in /home/auroraadmin85/public_html/Template/aurora/statbar.php on line 20 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: credits in /home/auroraadmin85/public_html/Template/aurora/main.php on line 56 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: networth in /home/auroraadmin85/public_html/Template/aurora/main.php on line 60 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: turns in /home/auroraadmin85/public_html/Template/aurora/main.php on line 64 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: energy in /home/auroraadmin85/public_html/Template/aurora/main.php on line 68 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: gas in /home/auroraadmin85/public_html/Template/aurora/main.php on line 72 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: ore in /home/auroraadmin85/public_html/Template/aurora/main.php on line 76 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: food in /home/auroraadmin85/public_html/Template/aurora/main.php on line 80 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: land in /home/auroraadmin85/public_html/Template/aurora/main.php on line 84 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: population in /home/auroraadmin85/public_html/Template/aurora/main.php on line 91 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: loyalty in /home/auroraadmin85/public_html/Template/aurora/main.php on line 95 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: population in /home/auroraadmin85/public_html/Template/aurora/main.php on line 102 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: prisoner in /home/auroraadmin85/public_html/Template/aurora/main.php on line 106 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: juggernaut in /home/auroraadmin85/public_html/Template/aurora/main.php on line 110 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: infantry in /home/auroraadmin85/public_html/Template/aurora/main.php on line 114 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: marauder in /home/auroraadmin85/public_html/Template/aurora/main.php on line 118 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: reconsq in /home/auroraadmin85/public_html/Template/aurora/main.php on line 122 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: terminator in /home/auroraadmin85/public_html/Template/aurora/main.php on line 126 [23-Feb-2014 01:05:05 UTC] PHP Notice: Undefined index: destroyer in /home/auroraadmin85/public_html/Template/aurora/main.php on line 130 basically I include a stat bar that has some information from the user displayed on the top of the page, as well as the page displays this info and more in detail. These two pages arent getting the data from the DB. statbar.php <?php error_reporting(E_ALL); include("safe.php"); include("functions.php"); if(!isset($_SESSION['uid'])){ echo "Please go back and log in"; }else{ ?> <div id="statbar"> <center> [Credits: <?php echo $user['username']; ?> ⊄] [Turns: <?php echo $user['turns']; ?>] [Biozene: <?php echo $user['gas']; ?>] [Energy: <?php echo $user['energy']; ?>] [Ore: <?php echo $user['ore']; ?>] [Food: <?php echo $user['food']; ?>] [Land: <?php echo $user['land']; ?>] [Population: <?php echo $user['population']; ?>] </center> </div> <?php } sorry its super long I know what the errors actually mean though, I just gotta figure out why its not receiving that data from the DB. the only thing it IS getting is the Username. Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470141 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 ah I figured out what was wrong. Must have missed it when I was duplicating the queries. they all say $user and they need to match the query in safe.php.. simple typos for this one.. Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470144 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 so it's all sorted out now? Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470148 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 yes that issue has been solved. now on to tackling a couple smaller issues that popped up but I should be able to figure them out. thank you all for the assistance! why will it let me echo $stats['credits'] and echo $unit['prisoner'] but not echo $user['commname'] or echo $structure['infirmary'] They both get their data from: safe.php <?php include("functions.php"); $stats_get = mysqli_query($myConnection,"SELECT * FROM `stats` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $stats = mysqli_fetch_assoc($stats_get); $unit_get = mysqli_query($myConnection,"SELECT * FROM `unit` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $unit = mysqli_fetch_assoc($unit_get); $user_get = mysqli_query($myConnection,"SELECT * FROM `user` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $user = mysqli_fetch_assoc($user_get); $structure_get = mysqli_query($myConnection,"SELECT * FROM `structure` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $structure = mysqli_fetch_assoc($structure_get); ?> I have a table called user, and structure and it wont retrieve data from those two, but it gets data from stats and units? Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470149 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 ah, that's good news dude. You're quite welcome. Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470152 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 ah, that's good news dude. You're quite welcome. I edited my post as you were replying Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470155 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 add this somewhere just to see what's in those two arrays, so you can see all the values and index names: echo '<pre>'; print_r($user); print_r($structure); echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470158 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 add this somewhere just to see what's in those two arrays, so you can see all the values and index names: echo '<pre>'; print_r($user); print_r($structure); echo '</pre>'; it returns Array ( [id] => 20 [username] => Tassadar [agridome] => 1 [spaceport] => 0 [barrack] => 5 [researchfac] => 0 [laserbat] => 0 [factory] => 0 [infirmary] => 1 [trainingfac] => 1 ) Notice: Undefined variable: structure in /home/auroraadmin85/public_html/Template/aurora/main.php on line 128 Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470162 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 see what's happening? 'commname' doesn't exist in there (are you sure theres a table field with that name in the database?) and the array $structure doesn't even exist for some reason. Are you sure you have a table called structure and that it has valid information for that specific user id you're using to pull stuff from the database? Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470164 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 see what's happening? 'commname' doesn't exist in there (are you sure theres a table field with that name in the database?) and the array $structure doesn't even exist for some reason. Are you sure you have a table called structure and that it has valid information for that specific user id you're using to pull stuff from the database? both tables structure and field commname exist for my user and matches the user ID on all tables. I can even provide a screenshot if ya need Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470168 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 and are you sure you should be grabbing the data based on the table's ID (as apposed to a field called UID (or some other name) that you should have in there, since id is just the primary key?) Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470170 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 I put the array print out at the top, requesting info from $user, $unit, $stats, Structure and it returned: Array ( [id] => 20 [username] => Tassadar [agridome] => 1 [spaceport] => 0 [barrack] => 5 [researchfac] => 0 [laserbat] => 0 [factory] => 0 [infirmary] => 1 [trainingfac] => 1 ) Array ( [id] => 20 [username] => Tassadar [credits] => 2000 [food] => 2000 [land] => 100 [energy] => 2000 [turns] => 30 [turns_max] => 30 [gas] => 2000 [ore] => 2000 [population] => 500 [buildeff] => 100 [offpts] => 0 [defpts] => 0 [score] => 0 [specialty] => Heavy Artillerist ) Array ( [id] => 20 [username] => Tassadar [trainee] => 100 [juggernaut] => 0 [infantry] => 50 [marauder] => 0 [terminator] => 0 [reconsq] => 0 [prisoner] => 0 [destroyer] => 0 [colossus] => 0 ) Notice: Undefined variable: structure in /home/auroraadmin85/public_html/Template/aurora/main.php on line 15 I suppose I could try and do it based on username? every table has an ID field in which they all match for every user, and have a Username field so Structures has ID, Username, etc... Units has ID, Username, etc.. Stats has ID, Username, etc.. User has ID, Username, etc... Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470172 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 and its weird it says undefined variable: structure when the print lists the structure table just fine.. but it didnt list $user at all to get info by username do I just change $stats_get = mysqli_query($myConnection,"SELECT * FROM `stats` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $stats = mysqli_fetch_assoc($stats_get); to $stats_get = mysqli_query($myConnection,"SELECT * FROM `stats` WHERE `username`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $stats = mysqli_fetch_assoc($stats_get); ? Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470173 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 hang on there... if you're referencing the user's info with his ID, what's the point of having the username repeated in all the databases (this makes it much harder is the username has to be changed for some reason)...Are you absalutely sure your script is accessing THAT database that you see in phpmyadmin, or do you have another copy somewhere? (because you're telling me a field called commname exists in the database, but select * isn't pulling it out. You must be giving me incorrect information somewhere. Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470174 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 you need to print out more stuff to find the problem. put the <pre> print_r(...) stuff after each of those database queries, and comment out any redirects that page might have, so you can see the data as soon as it's pulled from the database. so: $stats_get = mysqli_query($myConnection,"SELECT * FROM `stats` WHERE `id`='".$_SESSION['uid']."'") or die(mysqli_error($myConnection)); $stats = mysqli_fetch_assoc($stats_get); echo '<pre>'; print_r($stats); echo '</pre>'; (and do the same for all 4 queries) Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470175 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 hang on there... if you're referencing the user's info with his ID, what's the point of having the username repeated in all the databases (this makes it much harder is the username has to be changed for some reason)... Are you absalutely sure your script is accessing THAT database that you see in phpmyadmin, or do you have another copy somewhere? (because you're telling me a field called commname exists in the database, but select * isn't pulling it out. You must be giving me incorrect information somewhere. I did this because when I have thousands of users and when I need to look someone up I dont have to find them in the USER table, then match their ID with the ID on another table if I need to edit their data. I mean I shouldnt be doing it often so I could delete the username fields from all the tables except the user table. Ill post a screenshot of my structure so you can see the commname field is there, and that I have a structure table gimmie a bit Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470179 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 Heres a screen shot. Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470180 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 you really need to do what I said in my previous post, just after the $user query, please. I need to know it the info is being pulled out and lost somewhere else, or not being pulled out at all Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470184 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 its reporting: Array //<-----Stats ( [id] => 20 [credits] => 2000 [food] => 2000 [land] => 100 [energy] => 2000 [turns] => 30 [turns_max] => 30 [gas] => 2000 [ore] => 2000 [population] => 500 [buildeff] => 100 [offpts] => 0 [defpts] => 0 [score] => 0 [specialty] => Heavy Artillerist ) Array//<-----Unit ( [id] => 20 [trainee] => 100 [juggernaut] => 0 [infantry] => 50 [marauder] => 0 [terminator] => 0 [reconsq] => 0 [prisoner] => 0 [destroyer] => 0 [colossus] => 0 ) Array//<-----User ( [id] => 20 [colonynum] => 1 [username] => Tassadar [password] => 76d3399809a5646a8ddf9f63ce274c97 [email] => [email protected] [specialty] => Heavy Artillerist [commname] => Fenix [outpostname] => Mar Sara ) Array//<-----Structure ( [id] => 20 [agridome] => 1 [spaceport] => 0 [barrack] => 5 [researchfac] => 0 [laserbat] => 0 [factory] => 0 [infirmary] => 1 [trainingfac] => 1 ) Array ( [id] => 20 [credits] => 2000 [food] => 2000 [land] => 100 [energy] => 2000 [turns] => 30 [turns_max] => 30 [gas] => 2000 [ore] => 2000 [population] => 500 [buildeff] => 100 [offpts] => 0 [defpts] => 0 [score] => 0 [specialty] => Heavy Artillerist ) Array ( [id] => 20 [trainee] => 100 [juggernaut] => 0 [infantry] => 50 [marauder] => 0 [terminator] => 0 [reconsq] => 0 [prisoner] => 0 [destroyer] => 0 [colossus] => 0 ) Array ( [id] => 20 [colonynum] => 1 [username] => Tassadar [password] => 76d3399809a5646a8ddf9f63ce274c97 [email] => [email protected] [specialty] => Heavy Artillerist [commname] => Fenix [outpostname] => Mar Sara ) Array ( [id] => 20 [agridome] => 1 [spaceport] => 0 [barrack] => 5 [researchfac] => 0 [laserbat] => 0 [factory] => 0 [infirmary] => 1 [trainingfac] => 1 ) Here's something to really throw you for a loop.. it just.. fixed itself.. I didnt change anything, I even REMOVED those strings to print out the arrays and it works fine.. posting structures, units.. everything.. the only thing I did do was delete the username fields from all but the user table.. think that could have conflicted somehow? Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470187 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 no, that shouldn't have made a difference... Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470190 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 weird, its working flawlessly now Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470191 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 Cool! that's good news, because we're already on page 3 and it's much harder to keep going back and check things. I'm glad it's working Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470193 Share on other sites More sharing options...
Tassadar Posted February 23, 2014 Author Share Posted February 23, 2014 again, I appreciate the help. I know it has to be frustrating working with someone who isn't as skilled with PHP/SQL btw, in case you were wondering what the heck I am working on, its a space RTS game that is browser-based. that would explain all the strange fields and variables Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470195 Share on other sites More sharing options...
WebStyles Posted February 23, 2014 Share Posted February 23, 2014 you're welcome. I wish you luck with the rest of the game. If you run into any problems, you know where to come Link to comment https://forums.phpfreaks.com/topic/286396-login-issues/page/2/#findComment-1470196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.