Parse error

wxdqz

New Member
Hi,

I am trying to duplicate the example shown in this tutorial (<!-- m --><a class="postlink" href="http://www.mysql.com/articles/ddws/24.html">http://www.mysql.com/articles/ddws/24.html</a><!-- m -->), changing my database/table/variable names as required. I get a parse error on the line "if (isset($addhome)):" and I can't seem to figure it out. Worked til I added the form with the if/else etc.

Any help is greatly appreciated.
Thank you in advance.
Chuck

Here is the code I have.


<body bgcolor="teal">
<?php>

// If user wants to add a home
if (isset($addhome)):
?>

<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
<P>Enter your home here:<br>
<TEXTAREA NAME="LOCATION" ROWS=2 COLS=40 WRAP>
</TEXTAREA><BR>
<INPUT TYPE=SUBMIT NAME="submithome" VALUE=http://www.phpbuilder.com/board/archive/index.php/"SUBMIT">
</FORM>

<?php
else:

//Connect to server
$db = @mysql_connect("localhost", "root", "omta");
if (!$db) {
echo( "<P>Unable to connect.</P>" );
exit();
}

//Connect to database
mysql_select_db("REALESTATE", $db);
if (! @mysql_select_db("REALESTATE") ) {
echo( "<P>Unable to locate realestate database.</P>" );
exit();
}

// If home has been submitted, add.
if ("SUBMIT" == $submithome) {
$sql = "INSERT INTO HOMES SET " .
"LOCATION='$LOCATION', " .
"DATELISTED=CURDATE()";
if (mysql_query($sql)) {
echo("<P>Your home has been added.</P>");
}else("<P>Error adding home: " .
mysql_error() . "</P>";
}
}


//Select data from table
$result = mysql_query("SELECT LOCATION, SCHOOL FROM HOMES");

if (!$result) {
echo("<P>Error performing query: " . mysql_error() . "</P>");
exit();
}

//Display the text
while ( $row = mysql_fetch_array($result) ) {
echo("<P>" . $row["LOCATION"] . $row["SCHOOL"] . "</P>");
}

// Click this to add home.
echo("<P><A HREF='http://www.phpbuilder.com/board/archive/index.php/PHP_SELF?addhome=1'>" .
"Add a home!</A></P>");

endif;


?>
 
Back
Top