Forum Moderators: coopster

Message Too Old, No Replies

Session problems :-/

Sessions

         

Karandras

3:34 pm on Feb 20, 2004 (gmt 0)

10+ Year Member



Hey all, thanks for taking the time to look this over. My brain is hurting trying to figure this out. I've only been working with PHP for about a week now and I'm trying to get sessions to work in an onclick in a loop. Here is all the code (pw's for the dbase are missing of course). I have marked the line that PHP doesn't like. Thanks again!

<?php
session_start();
$dbconn = mysql_connect("", "", ""); //DataBase connection settings

if (!$dbconn) { //Connection Settings Verification
echo( "<P>Unable to connect to the database server at this time.</P>" );
exit();
}

mysql_select_db("independentofficegroup", $dbconn); //Connecting to the database

if (! @mysql_select_db("independentofficegroup") ) { //Connection Verification
echo("<P>Unable to locate the database at this time.</P>");
exit();
}

$sqlresult = mysql_query("SELECT * FROM tblProducts"); //finding all the products
if (!$sqlresult) {
echo("<P>Error performing query for all Products, please contact administrator</P>");
exit();
}
?>
<html>
<title>Teporary Products Page</title>
<body link="#000000" vlink="#000000" alink="#000000">
<table width="800" height="600"border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top">
<!--Start of top region-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="18%" height="78" align="left"><img src="/images/ilogo.gif"></td>
<td width="53%" align="center"><img src="/images/indylogo.gif"></td>
<td width="29%">&nbsp;</td>
</tr>
</table>
<!--End of top region-->
<!--Start of bottom region-->
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="500">
<tr>
<td width="150" height="500" align="left" valign="top"> <font size="2">
<?PHP
//This is the include for the left margin
include 'leftmargin.php';

?>
</font></td>
<!--Start of center-->
<td width="650" height="500" valign="top"> <table cellpadding="2" cellspacing="2">
<tr>
<td><center>
<strong>Picture</strong></center></td>
<td><center>
<strong>Name</strong></center></td>
<td><center>
<strong>Description</strong></center></td>
<td><center>
<strong>Features</strong></center></td>
</tr>
<?php
//Start Products Loop
while ($row = mysql_fetch_array($sqlresult)) {
$ProdIDTemp = $row["ProdID"]; //Temp ID for next SELECT query

echo("<tr>");

//**********START THE PROBLEM LINE*****************

echo("<td valign='top'><a href='test.php' onClick='" $_SESSION['ProdIDTemp'] = $ProdIDTemp "'><img border='0' src='/images/small/". $row["ProdImageSmall"]. "'></a></td>");

//**********END THE PROBLEM LINE*****************

echo("<td valign='top'>". $row["ProdName"]. "</td>");
echo("<td valign='top' width='350'>". $row["ProdDesc"]. "</td>");

$sqlresultProdFeat = mysql_query("SELECT ProdFeat1, ProdFeat2, ProdFeat3, ProdFeat4,
ProdFeat5, ProdFeat6, ProdFeat7, ProdFeat8
FROM tblProducts WHERE ProdID = ". $ProdIDTemp ." "); //
if (!$sqlresultProdFeat) {
echo("<P>Error performing query Product Feature Query, please contact administrator</P>");
exit();
}

while ($rowFeat = mysql_fetch_array($sqlresultProdFeat)) {
echo("<td valign='top' width='350'> <ul>");
$a = 9; //Max amount of feature (1-8)
for ($i = 1; $i < $a; $i++) {
if ($rowFeat["ProdFeat".$i]!= "") {
echo("<li>".$rowFeat["ProdFeat".$i]."</li>");
}
else{
}
}
echo("</ul></td>");
}
echo("</tr>");
echo("</form>");
}

?>
</table>
<p>&nbsp;</p>
</td>
</tr>
</table>
<!--End of center-->
</td>
</tr>
</table>
</body>
</html>

Karandras

3:38 pm on Feb 20, 2004 (gmt 0)

10+ Year Member



Guess I should tell you what I'm trying to do here.

<snip>

is trying to bring the value $ProdIDTemp to

<snip>

going to use this to load a more detailed view of the products listed.

[edited by: jatar_k at 4:44 pm (utc) on Feb. 20, 2004]
[edit reason] no personal urls thanks [/edit]

kumarsena

3:39 pm on Feb 20, 2004 (gmt 0)

10+ Year Member



what exactly is your error messege? besides, isnt onclick a javascript function? doubt u can use it just like that in your script.

Karandras

4:02 pm on Feb 20, 2004 (gmt 0)

10+ Year Member



The onclick works, its just not bringing the data through, or I'm not getting it properly on the other page. There is actually no error when I'm trying it. I've tried replacing:

$_SESSION['ProdIDTemp'] = $ProdIDTemp

with

$_SESSION['ProdIDTemp'] = time()

and I'm able to pull the data through onto the sencond page. Would there be a better way to do this?