What could be the problem?

A

abpteam

Hello everybody!

I have a javascript issue. I have to files: dashboard.php and
legoFront.class.php.

Here is dashboard.php code:

<?
require_once("classes/legoFront.class.php");
$classOBJ = new LegoFront();
$classOBJ->checkSecurity(session_id());

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$sid = session_id();
if ($_SESSION['ses_user_id']=="") {
header("Location: index.php?PHPSESSID=$sid");
exit;
}
?>


<!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=iso-8859-1" />
<title><?=$classOBJ->client_title?></title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="js/prototype.js"></script>
<script language="javascript" src="js/ajax.js"></script>
</head>

<body">
<table id="maintable" border="0" cellpadding="0" cellspacing="0">
<tr><td align="left" class="text01"><a href="" class='link'>How To
Play?</a> | <a href="" class='link'>Rules</a> | <a href="javascript:
showTweekABoard('<?=$sid?>')" class='link'>This Week Answers</a></
td><td align="right" class="text01"><a href="javascript: editProfile
('<?=$sid?>')" class='link'>Edit Profile</a> | <a href="javascript:
changePassword('<?=$sid?>')" class='link'>Change Password</a> | <a
href="javascript: logout('<?=$sid?>')" class='link'>Logout</a></td></
tr>
<tr>
<td colspan="2" align="center" valign="top" >
<? $classOBJ->inc_header()?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td align="center" width="50%"><div id="main_container"><?
if ($_SESSION['ses_cookies_status'] == 1) {
if ($_COOKIE['ses_mode']=="editProfile") {
$container = $classOBJ->editProfile($sid);
} else if ($_COOKIE['ses_mode']=="changePassword") {
$container = $classOBJ->changePassword($sid);
}
else if ($_COOKIE['ses_mode']=="showTweekABoard") {
$container = $classOBJ->showTweekABoard($sid);
}
else {
$container = $classOBJ->showDashBoard($sid);
}
} else {
if ($_SESSION['ses_mode']=="editProfile") {
$container = $classOBJ->editProfile($sid);
} else if ($_SESSION['ses_mode']=="changePassword") {
$container = $classOBJ->changePassword($sid);
} else if ($_SESSION['ses_mode']=="showTweekABoard") {
$container = $classOBJ->showTweekABoard($sid);
} else {
$container = $classOBJ->showDashBoard($sid);
}
}
?></div></td><td align="center">



<?
if ($_SESSION['ses_cookies_status'] == 1) {
if ($_COOKIE['ses_mode']=="thisWeek") {
$container = $classOBJ->thisWeek($sid);
} else if ($_COOKIE['ses_mode']=="lastWeek") {
$container = $classOBJ->lastWeek($sid);
} else {
$container = $classOBJ->showDashBoardMap($sid);
}
} else {
if ($_SESSION['ses_mode']=="thisWeek") {
$container = $classOBJ->thisWeek($sid);
} else if ($_SESSION['ses_mode']=="lastWeek") {
$container = $classOBJ->lastWeek($sid);
} else {
$container = $classOBJ->showDashBoardMap($sid);
}
}
?>
</td>
</tr>
<tr>
<td><img src="images/trans.gif" width="2" height="20" /></td>
</tr>
</table>
</td>
</tr>
</table>
<? $classOBJ->inc_footer()?>
</body>
</html>


||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
and in legoFront.class.php I have the functions but I'm putting only
two functions here:
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


function showTweekABoard($sid) {
$this->_connect();
$sql = "SELECT id, CONCAT(fname, ' ',lname) as name, last_login_time,
time_diff FROM lg_user_a WHERE id='".$_SESSION['ses_user_id']."'";
$result = $this->execute($sql);
$row = mysql_fetch_array($result);
$adjust_time = $row['time_diff']*(60*60);
$temp_time = strtotime($row['last_login_time']) - date("Z") +
$adjust_time;
$last_login_time = date('d M Y, h:i a', $temp_time);

if ($_SESSION['ses_js_status']=='1') {
?>
<table width="70%" border="0" align="center" cellpadding="2"
cellspacing="1" class="text01">
<tr>
<td colspan="2" align="center"><h2>This Week Answers</h2></td>
</tr>
<tr>
<td colspan="2"><img src="../images/trans.gif" width="5"
height="1" /></td>
</tr>
<tr>
<td colspan="2" align="left" class="text01" style="padding-left:
10px;"><div id="dashboardResponce">
Welcome <?=stripslashes($row['name'])?><br />
Your last login was on: <?=$last_login_time?><br /><br /><br /><br />
<?
print "<table width=100% border='0' cellspacing='0'
cellpadding='0'><tr><th align='center' class='text01'>Day</th><th
align='center' class='text01'>Answer</th><th align='center'
class='text01'>Latitude</th><th align='center'
class='text01'>Longitude</th></tr>";
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$result = mysql_query("SELECT * FROM thisweekanswers");
while($result1 = mysql_fetch_array($result))
{
print "<tr><td align='center'>{$result1['Day']}</td><td
align='right'>{$result1['Answer']}</td><td align='right'>{$result1
['Lat']}</td><td align='right'>{$result1['Lng']}</td></tr>";
}

?>
</div></td>
</tr>
</table>
<?
} else {
?>
<table width="70%" border="0" align="center" cellpadding="2"
cellspacing="1" class="text01">
<tr>
<td colspan="2" align="center"><h2>This Week Answers</h2></td>
</tr>
<tr>
<td colspan="2"><img src="../images/trans.gif" width="5"
height="1" /></td>
</tr>
<tr>
<td colspan="2" align="left" class="text01" style="padding-left:
10px;"><div id="dashboardResponce">
Welcome <?=stripslashes($row['name'])?><br />
Your last login was on: <?=$last_login_time?><br /><br /><br /><br />
<?
print "<table border='0' cellspacing='0' cellpadding='0'><tr><td
align='center' class='text01'>Day</td><td align='center'
class='text01'>Answer</td><td align='center' class='text01'>Latitude</
td><td align='center' class='text01'>Longitude</td></tr>";
$con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$result = mysql_query("SELECT * FROM thisweekanswers");
while($result1 = mysql_fetch_array($result))
{
print "<tr><td align='center'>{$result1['Day']}</td><td>{$result1
['Answer']}</td><td>{$result1['Lat']}</td><td>{$result1['Lng']}</td></
tr>";
}
}
?>
</div></td>
</tr>
</table>
<?

}


function showDashBoard($sid) {
$this->_connect();
$sql = "SELECT id, CONCAT(fname, ' ',lname) as name, last_login_time,
time_diff FROM lg_user_a WHERE id='".$_SESSION['ses_user_id']."'";
$result = $this->execute($sql);
$row = mysql_fetch_array($result);
$adjust_time = $row['time_diff']*(60*60);
$temp_time = strtotime($row['last_login_time']) - date("Z") +
$adjust_time;
$last_login_time = date('d M Y, h:i a', $temp_time);

if ($_SESSION['ses_js_status']=='1') {
?>
<table width="70%" border="0" align="center" cellpadding="2"
cellspacing="1" class="text01">
<tr>
<td colspan="2"><h2>DashBoard</h2></td>
</tr>
<tr>
<td colspan="2"><img src="../images/trans.gif" width="5"
height="1" /></td>
</tr>
<tr>
<td colspan="2" align="left" class="text01" style="padding-left:
10px;"><div id="dashboardResponce">
Welcome <?=stripslashes($row['name'])?><br />
Your last login was on: <?=$last_login_time?><br /><br /><br /><br />
<table width='310' border='0' cellspacing='1' cellpadding='2'
class='text01'>
<!--<tr>
<td width='1%' align='right'>&raquo;</td>
<td width='99%' align='left'><a href="javascript: editProfile
('...')" class='link'>Edit Profile</a></td>
</tr>
<tr>
<td width='1%' align='right'>&raquo;</td>
<td width='99%' align='left'><a href="javascript: changePassword
('...')" class='link'>Change Password</a></td>
</tr>
<tr>
<td width='1%' align='right'>&raquo;</td>
<td width='99%' align='left'><a href="javascript: logout('...')"
class='link'>Logout</a></td>
</tr>-->
<tr> <td align='center'>
<? $con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$result = mysql_query("SELECT * FROM pics where id=1");
$result1 = mysql_fetch_array($result);
print "<a href=".$result1['poza']." target='_blank'><img src=".
$result1['poza']." width='350' height='350'></a><br><br><b>OBJECTIVE:
".$result1['obiectiv']."<br>HINT: ".$result1['hint']."<br>Accepted
Error: ".$result1['erac']."<br></b>";
mysql_close($con);
?>
</table>
</div></td>
</tr>
</table>
<?
} else {
?>
<table width="70%" border="0" align="center" cellpadding="2"
cellspacing="1" class="text01">
<tr>
<td colspan="2"><h2>DashBoard</h2></td>
</tr>
<tr>
<td colspan="2"><img src="../images/trans.gif" width="5"
height="1" /></td>
</tr>
<tr>
<td colspan="2" align="left" class="text01" style="padding-left:
10px;"><div id="dashboardResponce">
Welcome <?=stripslashes($row['name'])?><br />
Your last login was on: <?=$last_login_time?><br /><br /><br /><br />
<table width='310' border='0' cellspacing='1' cellpadding='2'
class='text01'>
<tr>
<td width='1%' align='right'>&raquo;</td>
<td width='99%' align='left'><a href="edit_profile.php?PHPSESSID=<?=
$sid?>" class='link'>Edit Profile</a></td>
</tr>
<tr>
<td width='1%' align='right'>&raquo;</td>
<td width='99%' align='left'><a href="change_password.php?
PHPSESSID=<?=$sid?>" class='link'>Change Password</a></td>
</tr>
<tr>
" class='link'>Logout</a></td>
</tr>
<tr> <td colspan="2" align='center'>
<? $con = mysql_connect("","","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$result = mysql_query("SELECT * FROM pics where id=1");
$result1 = mysql_fetch_array($result);
print "<a href=".$result1['poza']." target='_blank'><img src=".
$result1['poza']." width='350' height='350'></a><br><br><b>OBJECTIVE:
".$result1['obiectiv']."<br>HINT: ".$result1['hint']."<br>Accepted
Error: ".$result1['erac']."<br></b>";
mysql_close($con);
?>
</table>
</div></td>
</tr>
</table>
<?
}
}

As you can see in dashboard.php in body section at the beginning I'm
calling functions from the legoFront.class.php for some links. Why
doesn't it works when I call the function showTweekABoard() for that
link?

What could be the problem? If I'm changing the code from
showTweekABoard() (only the code between showTweekABoard('$sid') { }
without the name of the function) with the code from showDashBoard()
it still doesn't work, but if I call the function showDashBoard() for
that link it works.

Why is that? I looked over all the files to see if the function
showDashBoard() is declared in another place but I didn't find any.

And this happens with all the new functions that I create in that file
and try to call them for a link.


Please help me,


Thank you,
Adrian
 
G

gisat

will give a better PHP code and JavaScript code in a file separately
for the sake of clarity?
 
R

RobG

Hello everybody!

I have a javascript issue. I have to files: dashboard.php and
legoFront.class.php.

Here is dashboard.php code:
[...]

Not interested. Post a minimal example based on the code in your
browser, or a link to a page, that demonstrates the issue. This isn't
a PHP group.

The minimal amount of javascript involved fails to declare local
variables, has syntax errors and calls to undefined functions.
 
T

Thomas 'PointedEars' Lahn

abpteam said:
I have a javascript issue. I have to files: dashboard.php and
legoFront.class.php.

[...]
<!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=iso-8859-1" />
<title><?=$classOBJ->client_title?></title>
[...]
<script language="javascript" src="js/prototype.js"></script>
<script language="javascript" src="js/ajax.js"></script>

<DM> Oh brother. </DM>

<http://www.simplemachines.org/community/index.php?topic=201049.0>
<http://validator.w3.org/>
<http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you>
[...]
Play?</a> | <a href="" class='link'>Rules</a> | <a href="javascript:
^^^^^^^^^^^
RTFFAQ. (See below.)
showTweekABoard('<?=$sid?>')" class='link'>This Week Answers</a></
^^^^^^^^^^^^^^^^
This is a client-side J(ava)Script/ECMAScript call.
[...]
function showTweekABoard($sid) {
$this->_connect();
$sql = "SELECT id, CONCAT(fname, ' ',lname) as name, last_login_time,
time_diff FROM lg_user_a WHERE id='".$_SESSION['ses_user_id']."'";
$result = $this->execute($sql);
$row = mysql_fetch_array($result);
$adjust_time = $row['time_diff']*(60*60);
$temp_time = strtotime($row['last_login_time']) - date("Z") +
$adjust_time;
$last_login_time = date('d M Y, h:i a', $temp_time);

if ($_SESSION['ses_js_status']=='1') {
?>
[...]

As indicated by the closing `?>', this is a server-side PHP function.

<http://jibbering.com/faq/#posting>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,757
Messages
2,569,543
Members
45,026
Latest member
camilin05

Latest Threads

Top