What's Here?
Members: 300,460
Replies: 826,089
Topics: 137,468
Snippets: 4,420
Tutorials: 1,148
Total Online: 1,654
Members: 84
Guests: 1,570
Loading. Please Wait...
about sessions (resolved )
about sessions (resolved ), (resolved )
peter yianni
1 Jul, 2009 - 12:28 PM
D.I.C Regular
Joined: 4 Jun, 2009
Posts: 308
Thanked: 2 times
My Contributions
question i hope it a easy one to resolve
i have a page that works fine using sesson this one here
CODE
<?php include("../php-login-script-v1.0/session.php"); require_once('../Connections/stablemaster.php'); $user_name = $_SESSION['user']; $user_id = $_SESSION['uid']; if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_stablemaster, $stablemaster); $query_Recordset1 = "SELECT stable_name, user_email, country FROM users WHERE id='".$user_id."'"; $Recordset1 = mysql_query($query_Recordset1, $stablemaster) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); mysql_select_db($database_stablemaster, $stablemaster); $query_horsehistory = "SELECT * FROM horse_stats WHERE stable_name = '".$row_Recordset1['stable_name']."'"; $horsehistory = mysql_query($query_horsehistory, $stablemaster) or die(mysql_error()); $row_horsehistory = mysql_fetch_assoc($horsehistory); $totalRows_horsehistory = mysql_num_rows($horsehistory); mysql_select_db($database_stablemaster, $stablemaster); $query_JOCKSTATS = "SELECT * FROM jocky_stats WHERE stable_name = '".$row_Recordset1['stable_name']."'"; $JOCKSTATS = mysql_query($query_JOCKSTATS, $stablemaster) or die(mysql_error()); $row_JOCKSTATS = mysql_fetch_assoc($JOCKSTATS); $totalRows_JOCKSTATS = mysql_num_rows($JOCKSTATS); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Stable Stats</title> <meta http-equiv="Expires" content="0" /> <META HTTP-EQUIV="cache-control" CONTENT="no-cache" /> <link href="file:///C|/wamp/www/WEBISTE BUILDING/Style Sheets/Fonts.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .Fonts tr td { color: #000; } #stable_finances tr td h1 { font-variant: small-caps; color: #FF0; } #stable_finances2 tr td h2 { background-color: #30F; color: #FF0; } --> </style> <link href="file:///C|/wamp/www/WEBISTE BUILDING/Style Sheets/heading2.css" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- body { background-color: #BFEBFF; } #stable_stats tr td div h2 { color: #00F; } #stable_stats tr td table tr td div { color: #FFF; } --> </style></head> <body onLoad="startTime()"> <div align="center"> <div align="center"> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> </tr> </table> </div> <div id="txt"></div> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#BFEBFF"><form name="form1" method="post" action=""> <table width="60%" border="0" align="center" cellpadding="1" cellspacing="1" id="stable_stats"> <tr> <td colspan="2" bgcolor="#BFEBFF"><div align="center"> <h2>Stable Stats</h2> </div></td> </tr> <tr> <td>Stable Name</td> <td><label for="stable_name"></label> <input name="stable_name" type="text" id="stable_name" value="<?php echo $row_Recordset1['stable_name']; ?>" size="30" maxlength="45" /></td> </tr> <tr> <td>Email</td> <td><label for="email"></label> <input name="email" type="text" id="email" value="<?php echo $row_Recordset1['user_email']; ?>" size="30" maxlength="40" /></td> </tr> <tr> <td>country</td> <td><label for="country"></label> <input name="country" type="text" id="country" value="<?php echo $row_Recordset1['country']; ?>" size="30" maxlength="20" /></td> </tr> </table> </form></td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="Fonts" id="stable_stats"> <tr> <td width="100%" bgcolor="#BFEBFF"><div align="center"> <h2> </h2> <h2>Current Horses</h2> </div></td> </tr> <tr> <td bgcolor="#FFFFFF"> <table width="100%" border="1" cellpadding="1" cellspacing="1"> <tr> <td width="13%" bgcolor="#0000FF"><div align="center">Name</div></td> <td width="10%" bgcolor="#0000FF"><div align="center">Age</div></td> <td width="10%" bgcolor="#0000FF"><div align="center">Gen</div></td> <td width="11%" bgcolor="#0000FF"><div align="center">Bred</div></td> <td width="10%" bgcolor="#0000FF"><div align="center">Xp</div></td> <td width="10%" bgcolor="#0000FF"><div align="center">Ran</div></td> <td width="11%" bgcolor="#0000FF"><div align="center">Won</div></td> <td width="12%" bgcolor="#0000FF"><div align="center">Shown</div></td> <td width="13%" bgcolor="#0000FF"><div align="center">Winnings</div></td> </tr> <?php do { ?> <tr> <td nowrap><a href="../Horse_history.php?horse=<?php echo $row_horsehistory['name_id']; ?>"><?php echo $row_horsehistory['name_id']; ?></a></td> <td><?php echo $row_horsehistory['age']; ?></td> <td><?php echo $row_horsehistory['gen']; ?></td> <td><?php echo $row_horsehistory['bred']; ?></td> <td><?php echo $row_horsehistory['xp']; ?></td> <td><?php echo $row_horsehistory['ran']; ?></td> <td><?php echo $row_horsehistory['won']; ?></td> <td><?php echo $row_horsehistory['shown']; ?></td> <td><?php echo $row_horsehistory['winnings']; ?></td> </tr> <?php } while ($row_horsehistory = mysql_fetch_assoc($horsehistory)); ?> </table></td> </tr> <tr> <td bgcolor="#BFEBFF"><div align="center"> <h2> </h2> <h2>Current Jockeys</h2> </div></td> </tr> <tr> <td><table width="100%" border="1" align="center" cellpadding="1" cellspacing="1"> <tr> <td bgcolor="#0000FF"><div align="center">Jocky Name</div></td> <td bgcolor="#0000FF"><div align="center">Age</div></td> <td bgcolor="#0000FF"><div align="center">Run</div></td> <td bgcolor="#0000FF"><div align="center">Won</div></td> <td bgcolor="#0000FF"><div align="center">Place</div></td> <td bgcolor="#0000FF"><div align="center">Moral</div></td> <td bgcolor="#0000FF"><div align="center">Rating</div></td> <td bgcolor="#0000FF"><div align="center">Winnings</div></td> </tr> <?php do { ?> <tr> <td bgcolor="#FFFFFF"><a href="../jocky_history.php?jocky=<?php echo $row_JOCKSTATS['Jocky_name']; ?>"><?php echo $row_JOCKSTATS['Jocky_name']; ?></a></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['age']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['run']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['won']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['place']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['moral']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['rating']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_JOCKSTATS['winnings']; ?></td> </tr> <?php } while ($row_JOCKSTATS = mysql_fetch_assoc($JOCKSTATS)); ?> </table><h2> </h2></td> </tr> </table> </form></td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> </td> </tr> </table> </div> </body> </html> <?php mysql_free_result($horsehistory); mysql_free_result($JOCKSTATS); mysql_free_result($Recordset1); ?>
i want to make this one use the same session but its just not happening.
i will put the pages as uploads the stable statistics.php is fine
the horse summary is not .
the page itself is ok but it comes up with all the horses instead of just the users horses here is the page
CODE
<?php require_once('Connections/stablemaster.php'); require_once('../Connections/stablemaster.php'); session_start(); if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_stablemaster, $stablemaster); $query_Recordset1 = "SELECT * FROM horse_stats"; $Recordset1 = mysql_query($query_Recordset1, $stablemaster) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!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=utf-8" /> <title>Horse summary</title> <style type="text/css"> <!-- body { background-color: #BFEBFF; color: #000; } --> </style> <link href="Style Sheets/FONTBLUE.css" rel="stylesheet" type="text/css" /></head> <?php do { ?> <table width="900" border="10" cellspacing="5" cellpadding="1"> <tr> <td width="150" bgcolor="#CCCCCC"><h3 align="center"> <a href="../Horse_history.php?horse=<?php echo $row_horsehistory['name_id']; ?>"> <?php echo $row_Recordset1['name_id']; ?></a></h3></td> <td nowrap="nowrap" bgcolor="#CCCCCC"><h4 align="center"> Overall Rating</h4></td> <td nowrap="nowrap" bgcolor="#CCCCCC"><h3 align="center"> <?php echo $row_Recordset1['xp']; ?></h3></td> <td nowrap="nowrap" bgcolor="#CCCCCC"><h3 align="center"> Date Time Details</h3></td> </tr> <tr> <td width="150" height="150" align="center" valign="top"><div align="center"> <img src='../Horse image/<?php echo $row_Recordset1["image"]?>' /></div></td> <td width="120" valign="top" nowrap="nowrap" class="FONTBLUE"> Age<br /> Gen<br /> Medical:<br /> Physical:<br /> Ran / Won<br /> Career earnings:<br /> Latest race:</td> <td width="150" valign="top" nowrap="nowrap"> (<?php echo $row_Recordset1['age']; ?>)<br /> <?php echo $row_Recordset1['gen']; ?><br /> <?php echo $row_Recordset1['medical_condition']; ?><br /> <?php echo $row_Recordset1['physical_condition']; ?><br /> (<?php echo $row_Recordset1['ran']; ?>)( <?php echo $row_Recordset1['won']; ?>)<br /> <?php echo $row_Recordset1['career_earnings']; ?><br /> <?php echo $row_Recordset1['latest_race']; ?><br /></td> <td width="480" align="left" valign="top" nowrap="nowrap"></td> </tr> </table> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> <p> </p> </body> </html> <?php mysql_free_result($Recordset1); ?>
i would apritiate the help as there is a lot of pages that will need to use the same sessions
This post has been edited by peter yianni : 2 Jul, 2009 - 10:20 AM
Attached File(s)
stable_statistics.php ( 9.33k )
Number of downloads: 2
Horse_summary.php ( 3.75k )
Number of downloads: 3
peter yianni
RE: About Sessions (resolved ) 1 Jul, 2009 - 01:18 PM
D.I.C Regular
Joined: 4 Jun, 2009
Posts: 308
Thanked: 2 times
My Contributions
QUOTE(MageUK @ 1 Jul, 2009 - 01:16 PM)
You need to call session_start() within the second script.
its there
<?php require_once('Connections/stablemaster.php');
require_once('../Connections/stablemaster.php');
session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
RudiVisser
RE: About Sessions (resolved ) 1 Jul, 2009 - 01:31 PM
.. does not guess solutions
Joined: 5 Jun, 2009
Posts: 1,872
Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#
My Contributions
Ah duh, it's late.
Under
session_start() , try adding
print_r($_SESSION); , if it prints out correct values then you know it's nothing to do with session handling and is to do with the query or something different
RudiVisser
RE: About Sessions (resolved ) 1 Jul, 2009 - 11:06 PM
.. does not guess solutions
Joined: 5 Jun, 2009
Posts: 1,872
Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#
My Contributions
QUOTE(noorahmad @ 1 Jul, 2009 - 08:59 PM)
You need Start Session at top of every page
page1.php
php
if(!isset($_SESSION)) { session_start(); } $_SESSION['username']= 'anything'; // declaring and assigning value to session variablepage2.php
php
if(!isset($_SESSION)) { session_start(); } echo $_SESSION['username']; //printing session in our pageand i also attached your files.
Can you actually read? The session is fine.
RudiVisser
RE: About Sessions (resolved ) 1 Jul, 2009 - 11:24 PM
.. does not guess solutions
Joined: 5 Jun, 2009
Posts: 1,872
Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#
My Contributions
QUOTE(noorahmad @ 1 Jul, 2009 - 11:18 PM)
QUOTE
Can you actually read? The session is fine.
is there any wrong? can you solve it? may be i am in basic of PHP can make it advance?
Yes I can solve it because I don't
guess everything .
peter_yianni, on the second page, under the
mysql_select_db and where
$Recordset1 is created, add this:
CODE
$stable_nameQ = mysql_query("SELECT stable_name FROM users WHERE id='".$_SESSION['uid']."'"); $stable_nameA = mysql_fetch_assoc($stable_nameQ); $query_Recordset1 = "SELECT * FROM horse_stats WHERE `stable_name` = '".$stable_nameA['stable_name']."';";
Replace the query_Recordset1 line with the above.
hadi_php
RE: About Sessions (resolved ) 1 Jul, 2009 - 11:51 PM
D.I.C Regular
Joined: 23 Aug, 2008
Posts: 259
Thanked: 5 times
My Contributions
CODE
$stable_nameQ = mysql_query("SELECT stable_name FROM users WHERE id='".$_SESSION['uid']."'");
if it occurs error..then
CODE
$id = $_SESSION['uid']; $stable_nameQ = mysql_query("SELECT stable_name FROM users WHERE id= $id");
if you want then ..........
U need to assign an array where ur session values were created. After array declaration session value will print.
RudiVisser
RE: About Sessions (resolved ) 2 Jul, 2009 - 12:06 AM
.. does not guess solutions
Joined: 5 Jun, 2009
Posts: 1,872
Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#
My Contributions
There's nothing to escape? The session is being entered external from the string via concatenation, and the value of session is being added from a seperate script where this sort of filtering should be performed.
To be safe"r" a better option would be to just do:
CODE
$stable_nameQ = mysql_query("SELECT `stable_name` FROM `users` WHERE `id` = '" . mysql_real_escape_string($_SESSION['uid']) . "'");
But the relevant filtering should be applied already once the login has commenced.
Aaaah you edited, seeeeee
This post has been edited by MageUK : 2 Jul, 2009 - 12:07 AM
peter yianni
RE: About Sessions (resolved ) 2 Jul, 2009 - 10:13 AM
D.I.C Regular
Joined: 4 Jun, 2009
Posts: 308
Thanked: 2 times
My Contributions
QUOTE(MageUK @ 1 Jul, 2009 - 11:24 PM)
QUOTE(noorahmad @ 1 Jul, 2009 - 11:18 PM)
QUOTE
Can you actually read? The session is fine.
is there any wrong? can you solve it? may be i am in basic of PHP can make it advance?
Yes I can solve it because I don't
guess everything .
peter_yianni, on the second page, under the
mysql_select_db and where
$Recordset1 is created, add this:
CODE
$stable_nameQ = mysql_query("SELECT stable_name FROM users WHERE id='".$_SESSION['uid']."'"); $stable_nameA = mysql_fetch_assoc($stable_nameQ); $query_Recordset1 = "SELECT * FROM horse_stats WHERE `stable_name` = '".$stable_nameA['stable_name']."';";
Replace the query_Recordset1 line with the above.
thank u its all working much apritiated also thanks the everyone one else who helped