Hi there guys,
I've got a script on two servers. On one, it does what it should, but on the other, although I'm defining cases(action=myaction), it always picks the default.
Working enviroment:
linux
php: 4.3.11
mysql: 3.23.49(info.php)
Non working enviroment:
linux
php: 4.4.2 (info.php)
mysql: 4.1.19
The script:
<?
include("../config.php");
echo ("
<html>
<head>
<title>Automonial Administration</title>
<script language=\"javascript\" type=\"text/javascript\">
<!--
/****************************************************
Author: Eric King
Url: http://redrival.com/eak/index.shtml
This script is free to use as long as this info is left in
Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos==\"random\"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos==\"center\"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!=\"center\" && pos!=\"random\") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>
</head>
<body>
<p align=left>Welcome to the Automonial administration panel.</p>
<p align=left><a href=index.php>Admin Index</a> -|-
<a href=index.php?action=waiting>View Waiting submissions</a> -|-
<a href=index.php?action=approved>View Approved Submissions</a> -|-
<a href=index.php?action=configure>Configuration</a>
</p>
<br>");
switch ($action) {
case "waiting" :
$query = "SELECT id,active,author,title,testtext," .
"DATE_FORMAT(postdate, '%M %D, %Y') as date " .
"FROM testimonials WHERE active=0 ORDER BY postdate DESC";
$result = mysql_query ($query);
while ($row = mysql_fetch_assoc ($result)) {
/* display testimonials in a simple table */
$date = $row['date'];
$author = stripslashes ($row['author']);
$title = stripslashes ($row['title']);
$testtext = stripslashes ($row['testtext']);
/* display the data */
echo("<div align=center>
<table width=90% border=1 cellpadding=1 cellspacing=1>
<tr>
<td bgcolor='#ffffff' width=400>
<font size=3><b>$title</b></font>
</td>
<td bgcolor='#ffffff' width=200>Added On: $date
</td>
</tr>
<tr>
<td bgcolor='#ffffff' colspan=2>
<font size=1>Posted By: $author</font>
</td>
</tr>
<tr>
<td bgcolor='#ffffff' colspan=2>
<font size=2>$testtext</font><p>
</td>
</tr>
</table>
</div><br>
<br>");
}
break;
case "approved" :
/* this query will get all of the testimonials */
$query = "SELECT id,active,author,title,testtext," .
"DATE_FORMAT(postdate, '%M %D, %Y') as date " .
"FROM testimonials WHERE active=1 ORDER BY postdate DESC";
$result = mysql_query ($query);
while ($row = mysql_fetch_assoc ($result)) {
/* display testimonials in a simple table */
$date = $row['date'];
$author = stripslashes ($row['author']);
$title = stripslashes ($row['title']);
$testtext = stripslashes ($row['testtext']);
/* display the data */
echo("<div align=center>
<table width=90% border=1 cellpadding=1 cellspacing=1>
<tr>
<td bgcolor='#ffffff' width=400>
<font size=3><b>$title</b></font>
</td>
<td bgcolor='#ffffff' width=200>Added On: $date
</td>
</tr>
<tr>
<td bgcolor='#ffffff' colspan=2>
<font size=1>Posted By: $author</font>
</td>
</tr>
<tr>
<td bgcolor='#ffffff' colspan=2>
<font size=2>$testtext</font><p>
</td>
</tr>
</table>
</div><br>
<br>");
}
break;
case "configure" :
break;
default :
echo ("
<p><b>Current statistics:</b></p>
<ul>
<li>Total Testimonials: ");
$query = mysql_query("SELECT * FROM testimonials");
$total = mysql_num_rows($query);
if($total==0)
{
echo ("0");
}else{
echo $total;
}
echo ("</li>
<li>Approved: ");
$query = mysql_query("SELECT * FROM testimonials WHERE active=1");
$total_app = mysql_num_rows($query);
if($total_app==0)
{
echo ("0");
}else{
echo $total_app;
echo (" (<a href=index.php?action=approved><i>view</i></a>)");
}
echo ("</li>
<li>Waiting: ");
$query = mysql_query("SELECT * FROM testimonials WHERE active=0");
$total_wait = mysql_num_rows($query);
if($total_wait==0)
{
echo ("0");
}else{
echo $total_wait;
echo (" (<a href=index.php?action=waiting><i>view</i></a>)");
}
echo ("</li>
</ul>
");
}
echo ("
</body>
</html>");
?>
On the working server, the actions(passed through the URL) cause the script to do what they're supposed to do; i.e. view waiting and approved text, and configuration. If no action is defined, it shows the stats.
On the non-working server, regardless of the link that I click, I get the default stats, and that's all.
Can anyone tell me what's in the script that would cause it to work fine in one enviroment, but not in the other?
thanks,
json