School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,150 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,866 people online right now. Registration is fast and FREE... Join Now!



View Date From Datbase

View Date From Datbase Rate Topic: -----

#1 nick1200  Icon User is offline

  • Php Coder
  • Icon
  • Group: Contributors
  • Posts: 735
  • Joined: 21-March 09


Dream Kudos: 50

Posted 02 April 2009 - 06:12 AM

i just posted my login script on here and fixed it but i found anothe rproblem now :v:

i donno if i can post to post a day or ?? but if im doing somthing wrong plz tell me :^:


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:
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


<?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


   <?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




<?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 :v:

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

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

This post has been edited by nick1200: 02 April 2009 - 06:24 AM

Was This Post Helpful? 0
  • +
  • -


#2 nick1200  Icon User is offline

  • Php Coder
  • Icon
  • Group: Contributors
  • Posts: 735
  • Joined: 21-March 09


Dream Kudos: 50

Posted 02 April 2009 - 06:27 AM

i fixed it now i replaced



$_SESSION[valid_user]'";

with

$_SESSION['username'];


thanks :^:
Was This Post Helpful? 0
  • +
  • -

#3 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • Icon
  • Group: Members w/DIC++
  • Posts: 820
  • Joined: 16-March 09


Dream Kudos: 25

Posted 02 April 2009 - 06:37 AM

If this is the login script i pointed you to you can also use the object variables that it assigns from session.php...

 
$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

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

/* 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 :)

This post has been edited by RPGonzo: 02 April 2009 - 06:38 AM

Was This Post Helpful? 0
  • +
  • -

#4 nick1200  Icon User is offline

  • Php Coder
  • Icon
  • Group: Contributors
  • Posts: 735
  • Joined: 21-March 09


Dream Kudos: 50

Posted 02 April 2009 - 06:45 AM

yaa i fixed it :P :P

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 :^:


thanks


you have learnt me a lot :D

This post has been edited by nick1200: 02 April 2009 - 06:47 AM

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

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

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month