I've looked over this a lot and tried a lot of different things, but I have not been able to figure out why I keep getting an error at the very last line of my script. Does anyone see any problems? Please, I really need some help - I'm stumped. It's not a terribly complex program, just something where you can add information or remove information, but removing requires a password.
"<b>Parse error</b>: parse error, unexpected $ in <b>C:\apache\htdocs\index.php</b> on line <b>135</b><br />"
Here's my code:
<HTML>
<HEAD>
<TITLE> Information </TITLE>
<HEAD>
<BODY>
<?php
// If the user wants to add information
if (isset($addjoke)):
?>
<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
<P>Type your information here:<BR>
<TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP>
</TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME="submitinfo" VALUE="SUBMIT">
</FORM>
<?php
else:
// Connect to the database server
$dbcnx = @mysql_connect(
"localhost", "rosemont_mark", "mark");
if (!$dbcnx)
{
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
// Select the information database
if (! mysql_select_db("rosemont_general"))
{
echo( "<P>Unable to locate the information " .
"database at this time.</P>" );
exit();
}
// If information has been submitted,
// add it to the database.
if ("SUBMIT" == $submitjoke)
{
$sql = "INSERT INTO information1 SET " .
"infotext='$joketext', " .
"infodate=CURDATE()";
if (mysql_query($sql))
{
echo("<P>Your information has been added.</P>");
}
else
{
echo("<P>Error adding submitted information: " .
mysql_error() . "</P>");
}
}
// If information has been deleted,
// remove it from the database.
if (isset($deletejoke)) {
?>
You must insert a password to delete information number
<?php
echo ("$deletejoke");
?>.
<FORM ACTION=<?php echo("$PHP_SELF"); ?> METHOD=GET>
Password: <INPUT TYPE=TEXT NAME="password">
<INPUT TYPE=HIDDEN NAME="deletejoke" VALUE="<?=$deletejoke?>">
<INPUT TYPE=SUBMIT VALUE="Continue">
</FORM>
<?php
if($password=="tequila") {
echo("<p>Password is correct.");
$sql = "DELETE FROM information1 " .
"WHERE ID=$deletejoke";
if (mysql_query($sql))
{
echo("<P>The information has been deleted.</P>");
}
if($password!="tequila" and isset($password)) {
echo("<p>Password is incorrect.");
}
}
if($password!="tequila" and !isset($password))
{
echo("<P>Error deleting information: " .
mysql_error() . "</P>");
}
}
echo("<P> Here is all the information " .
"in our database: </P>");
// Request the ID and text and date of all the information
$result = mysql_query(
"SELECT ID, infotext, infodate FROM information1");
if (!$result)
{
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
// Display the text of each joke in a paragraph
// with a "Delete this Information" link next to each.
while ( $row = mysql_fetch_array($result) )
{
$jokedate = $row["infodate"];
$jokeid = $row["ID"];
$joketext = $row["infotext"];
echo("<P>$jokedate - " .
"$joketext " .
"<A HREF='$PHP_SELF?deletejoke=$jokeid'>" .
"Delete this information</A></P>");
}
// When clicked, this link will load this page
// with the information submission form displayed.
echo("<P><A HREF='$PHP_SELF?addjoke=1'>" .
"Add information.</A></P>");
?>
</body>
</html>