PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,338 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,683 people online right now. Registration is fast and FREE... Join Now!




View Date From Datbase

 

View Date From Datbase

nick1200

2 Apr, 2009 - 06:12 AM
Post #1

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions
i just posted my login script on here and fixed it but i found anothe rproblem now icon_down.gif

i donno if i can post to post a day or ?? but if im doing somthing wrong plz tell me icon_up.gif


i am trying to get the pokemon lvl of user thats loged in so if i log in has shadow i wanna get pokemon1 pokemon2 pokemon3 pokemon 4 pokemon5 pokemon6

date from the database just for shadow rolleyes.gif
this is the script im using it was working good on my old site but just tryed to switch it over and it ent saying no errors but dont show the lvls

View Your Pokemon.php

CODE


<?php
    // this is the include to be able to display the SAME information mulitple times wihtout writting it multiple times
    include_once('pokemon_level.php');
    // end file include
?>





Pokemon_level.php

CODE


   <?php        

$sql = "SELECT Pokemon1, Pokemon2, Pokemon3, Pokemon4, Pokemon5, Pokemon6 FROM users WHERE username='$_SESSION[valid_user]'";

$result = mysql_query($sql) or die(mysql_error());

$values = mysql_fetch_array($result);


// this is the include to be able to display the SAME information mulitple times wihtout writting it multiple times
    include_once('config.php');
    // end file include
    
?>

                   <td align="center"><p><img src="pokemon/004.gif" width="32" height="32">

                     <p>Pokemon 1 Levell: <?php echo $values['level']; ?> </p>



                   <td align="center"><p><img src="pokemon/005.gif" width="32" height="32">

                     <p>Pokemon 2 Level: <?php echo $values['Pokemon2']; ?> </p>



                   <td align="center"><p><img src="pokemon/006.gif" width="32" height="32">

                     <p>Pokemon 3 Level: <?php echo $values['Pokemon3']; ?> </p>

                     <p>



                                    <td align="center"><p><img src="pokemon/006.gif" width="32" height="32">

                                      <p>Pokemon 4 Level: <?php echo $values['Pokemon4']; ?> </p>

                                      <p></p></td>

                   <p>



                                    <td align="center"><p><img src="pokemon/005.gif" width="32" height="32">

                                      <p>Pokemon 5 Level: <?php echo $values['Pokemon5']; ?> </p>

                                      <p></p></td>

                   <p>



                                    <td align="center"><p><img src="pokemon/004.gif" width="32" height="32">

                                      <p>Pokemon 6 Level: <?php echo $values['Pokemon6']; ?> </p>

                                      <p></p></td>

                 </tr>

               </table>


Config.php


CODE



<?php
mysql_connect("mysq.com", "admin", "nike4eva");
mysql_select_db("a1979179_pokemon");
?>



i have got sessions on the site has well but the session file is to big icon_down.gif

i have noticed my session uses $_SESSION['username'];

and pokemon_lvl.php uses $_SESSION[valid_user]'";

This post has been edited by nick1200: 2 Apr, 2009 - 06:24 AM

User is offlineProfile CardPM
+Quote Post


nick1200

RE: View Date From Datbase

2 Apr, 2009 - 06:27 AM
Post #2

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions


i fixed it now i replaced



$_SESSION[valid_user]'";

with

$_SESSION['username'];


thanks icon_up.gif
User is offlineProfile CardPM
+Quote Post

RPGonzo

RE: View Date From Datbase

2 Apr, 2009 - 06:37 AM
Post #3

// Note to self: hmphh .... I forgot
Group Icon

Joined: 16 Mar, 2009
Posts: 743



Thanked: 89 times
Dream Kudos: 25
My Contributions
If this is the login script i pointed you to you can also use the object variables that it assigns from session.php...

CODE

$session->username  // is $_SESSION['username']
$session->userid    // is $_SESSION['userid']
$session->userlevel = // is $_SESSION['userlevel']


you can add to the variables quite easily to pull more information and store it for later use

CODE

var $username;     //Username given on sign-up
var $userid;       //Random value generated on current login
var $userlevel;    //The level to which the user pertains
var $time;         //Time user was last active (page loaded)
var $logged_in;    //True if user is logged in, false otherwise
var $userinfo = array();  //The array holding all user info
var $url;          //The page url current being viewed
var $referrer;     //Last recorded site page viewed
// add variables here first
var $pokemon1; // 1st pokemon
var $pokemon2; // 2nd pokemon
var $pokemon3; // 3rd pokemon
// more to your liking


than where it assigns these variables

CODE

/* Username and password correct, register session variables */
$this->userinfo  = $database->getUserInfo($subuser);
$this->username  = $_SESSION['username'] = $this->userinfo['username'];
$this->userid    = $_SESSION['userid']   = $this->generateRandID();
$this->userlevel = $this->userinfo['userlevel'];
// just add more
$this->pokemon1 = $_SESSION['pokemon1'] = $this->userinfo['pokemon1'];
// add as many as you want


just be aware you need to assign the variables up top before you start giving them values or you wont be able to access those values smile.gif

This post has been edited by RPGonzo: 2 Apr, 2009 - 06:38 AM
User is offlineProfile CardPM
+Quote Post

nick1200

RE: View Date From Datbase

2 Apr, 2009 - 06:45 AM
Post #4

D.I.C Addict
****

Joined: 21 Mar, 2009
Posts: 551



Thanked: 6 times
My Contributions
yaa i fixed it tongue.gif tongue.gif

it was looking for sessions vaild_user

but the new login script makes the session username not vaild_user


so changed it from vaild_user to username icon_up.gif


thanks


you have learnt me a lot biggrin.gif

This post has been edited by nick1200: 2 Apr, 2009 - 06:47 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 05:18PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month