Forum Moderators: coopster
I am struggling with trying to get a page to load itself again. the PHP_SELF part seems to be the problem. Is it possible to use and echo inside a print or echo statement? I get this type of error
"Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in ...."
Any assistance would be great
while ($line4 = mysql_fetch_array($result4, MYSQL_ASSOC))
{
echo "\t<tr>\n";
foreach($line4 as $col_value)
{
echo "<td><font size=2>$col_value</td>";
}
echo "\t</tr>";
$i = $i + 1;
if($i==5)
{
echo "<tr>";
echo "<td colspan=5>";
print "<form method=\"post\" action=\"<?php echo $_SERVER['PHP_SELF'];?>\">\";<font size=2>Organisational Goal ID: <input type=\"text\" name=\"delete\"><input type=\"submit\" name=\"submit\" value=\"Delete Vulnerability\"></form>";
echo "</td>";
echo "</tr>";
$i=1;
}
}
echo "</table>\n";
Thanks and Cheers
Ty
$self = $_SERVER['PHP_SELF'];
and put this instead
print "<form method=\"post\" action=\'<?php echo $self;?>\'>\";<font size=2>Organisational Goal ID: <input type=\"text\" name=\"delete\"><input type=\"submit\" name=\"submit\" value=\"Delete Vulnerability\"></form>";
see if that works.
while ($line4 = mysql_fetch_array($result4, MYSQL_ASSOC))
{
echo "\t<tr>\n";
foreach($line4 as $col_value)
{
echo "<td><font size=2>$col_value</td>";
}
echo "\t</tr>";
$i = $i + 1;
if($i==5)
{
$e = "ec";
$h = "ho";
$self = $_SERVER['PHP_SELF'];
echo "<tr>";
echo "<td colspan=5><form method=\"post\" action=\"<?php $e$h $self?>\">\";<font size=2>Organisational Goal ID: <input type=\"text\" name=\"delete\"><input type=\"submit\" name=\"submit\" value=\"Delete Vulnerability\"></form>";
echo "</td>";
echo "</tr>";
$i=1;
}
}
echo "</table>\n";
print "<form method=\"post\" action=\'<?php echo $self;?>\'>\";<font size=2>Organisational Goal ID:....
No can do. What this should print if you look at view source is
<form method="post" action='<?php echo $self;?>'>";<font size=2>Organisational Goal ID:....
What you want is to use variable parsing or [url=http://php.net/manual/en/language.operators.string.php]concatenation [php.net] strings like so
1. concatenation with double quotes
print "<form method='post' action='" . $_SERVER['PHP_SELF'] . "'><font size='2'>Organisational";
[Note that I do not need to escape single quotes within double quotes]
2.substitution with double quotes and an array
print "<form method='post' action='{$_SERVER['PHP_SELF']}'><font size='2'>Organisational";
3. substitution with a simple variable
$self = $_SERVER['PHP_SELF'];
print "<form method='post' action='$self'><font size='2'>Organisational";
4. concatenation with single quotes
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '"><font size="2">Organisational';