Jump to content

PHP 5 not passing variable


nex1234

Recommended Posts

It appears that that my code fails to pass variables.  Everything works fine in PHP 4 but fails in PHP 5.  Any suggestions?

<!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>MPS Project Tracking</title>
</head>
<?php

if(!isset($_GET['table'])) {
die("You must have a table name set in the query string.");
}

$table = $_GET['table'];
$name = $_GET['name'];

mysql_connect("localhost", "----", "----");
mysql_select_db("mps");

function returnheaders() {
global $table;
$sql = mysql_query("SELECT * FROM `$table` LIMIT 1") or die(mysql_error()); // `` enables table names with #'s
$array = mysql_fetch_array($sql);
foreach($array as $key => $value) {
	if(!is_numeric($key) && $key != "id") {
		echo("<td id=\"header_$key\">$key</td>\n");
	}
}
}
function returndata() {
global $table;
$sql = mysql_query("SELECT * FROM `$table`"); // `` enables table names with #'s
while($row = mysql_fetch_array($sql)) {
	echo("<tr id=\"dataset_row".$row['id']."\">\n");
	foreach($row as $key => $value) {
		if(!is_numeric($key) && $key != "id") {
			echo("<td id=\"".$key.$row['id']."\" nowrap><a id=\"".$key."_".$row['id']."_value\" href=\"javascript:edit_row(".$row['id'].");\">".$value."</a></td>\n");
		}
	}
	echo("</tr>\n");


}
}
function loaddynamicjava() {
global $table;
echo("<script type=\"text/javascript\">\nvar readylight = true;\nfunction edit_row(row) {\nvar currentval;\n");
$sql = mysql_query("SELECT * FROM `$table` WHERE id=1") or die(mysql_error()); // `` enables table names with #'s
$array = mysql_fetch_array($sql);
foreach($array as $key => $value) {
	if(!is_numeric($key) && $key != "id") {
		echo("currentval = document.getElementById(\"".$key."_\"+row+\"_value\").innerHTML;\n");
		echo("document.getElementById(\"".$key."\"+row).innerHTML = ");
		if($key == "Permit_Process")
			echo("'<input type=\"button\" name=\"save\" value=\"Save\" onClick=\"savedata('+row+');\">");
		else
			echo("'");
		echo("<input type=\"text\" id=\"".$key."_'+row+'\" name=\"".$key."_'+row+'\" value=\"'+currentval+'\" />';\n");
	}
}
echo("}\nfunction savedata(row) {\nif(!ready) { alert(\"Database is still saving other data!\"); return; }\nready = false;\nvar currentdata;");
foreach($array as $key => $value)
	if(!is_numeric($key))
		if($key == "id")
			echo("document.getElementById(\"id\").value = row;\n");
		else
			echo("document.getElementById(\"".$key."\").value = document.getElementById(\"".$key."_\"+row).value;\n");
echo("document.getElementById(\"theform\").submit();\n");
foreach($array as $key => $value)
	if(!is_numeric($key) && $key != "id") {
		echo("currentdata = document.getElementById(\"".$key."_\"+row).value;\n");
		echo("document.getElementById(\"".$key."\"+row).innerHTML = '<a href=\"javascript:edit_row('+row+');\" id=\"".$key."_'+row+'_value\">'+currentdata+'</a>';\n");
	}

echo("}\nfunction nowready() { ready = true; }</script>");
}
function returnformfields() {
global $table;
$sql = mysql_query("SELECT * FROM `$table` LIMIT 1"); // `` enables table names with #'s
$array = mysql_fetch_array($sql);
foreach($array as $key => $value)
	if(!is_numeric($key))
		echo("<input type=\"hidden\" name=\"".$key."\" id=\"".$key."\" />\n");
echo("<input type=\"hidden\" name=\"table\" value=\"$table\" />\n");
}
?>
<?php loaddynamicjava(); ?>
<b><u>MPS PROJECT TRACKING</u></b><br /><br />
<a href="javascript:history.back();">Back</a> <a href="../home.php">Home</a><br /><br />
Project Number: <?php echo $table; ?><br />
Project Name: <?php echo $name; ?><br /><br />
<table border="1" cellpadding="0" cellspacing="0">
<tr class="header"><?php returnheaders(); ?></tr>
    <?php returndata(); ?>
</table>
<form action="update.php" method="post" target="hiddenframe" name="theform" id="theform">
<?php returnformfields(); ?>
</form>
<br />
<a href="../report/create.php?table=<?=$_GET['table'];?>&name=<?=$_GET['name'];?>">Create a report for this project.</a><br />
<a href="../report/view.php?table=<?=$_GET['table'];?>">View reports for this project.</a><br />
<a href="javascript:window.print();">Print this page.</a>
<iframe src="about:blank" style="display: none;" name="hiddenframe" id="hiddenframe" onLoad="nowready();">This page requires iFrames which your browser does not support.</iframe>
<body bgcolor="#00FFFF" background="ripple.jpg">
<style type="text/css">
a:link {color: #0000FF}
a:visited {color: #0000FF}
a:hover {color: #0000FF}
a:active {color: #0000FF}
</style>
</font>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/113800-php-5-not-passing-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.