ecosvaldo
asked on
Script for Admin section of a Site Not Working - NEED HELP!!!
I'm having a problem with a PHP script for the admin section of a site I'm working on. The following script is below:
<html>
<body>
<?php
$db = mysql_connect("localhost", "i24-7hom_admin", "hotline");
mysql_select_db("i24-7hom_ home",$db) ;
if ($submit) {
// here if no ID then adding else we're editing
if ($housecode) {
$sql = "UPDATE home SET address='$address',city='$ city',stat e='$state' ,zip='$zip code',pric e='$price' ,beds='$be d',bath='$ bath',gara ge='$garag e',rooms=' $room',lot range='$lo t',built=' $yearbuilt ',levels=' $levels',f ireplace=' $fireplace ',centrala ir='$centr alair',zon ed='$zoned ',gas='$ga s',forceda ir='$force dair',scho oldistrict ='$schoold istrict',e lementarys chool='$el ementary', middlescho ol='$middl e',highsch ool='$high ',county=' $county',e xterior='$ exterior', propertyty pe='$prope rty',style ='$style', parking='$ parking',c ontactphon e='$phone' ,contactem ail='$emai l',descrip tion='$des cription' WHERE housecode=$housecode";
} else {
$sql = "INSERT INTO home (housecode,address,city,st ate,zip,pr ice,beds,b ath,garage ,rooms,lot range,buil t,levels,f ireplace,c entralair, zoned,gas, forcedair, schooldist rict,eleme ntaryschoo l,middlesc hool,highs chool,coun ty,exterio r,property type,style ,parking,c ontactphon e,contacte mail,descr iption) VALUES ('$housecode','$address',' $city','$s tate','$zi pcode','$p rice','$be d','$bath' ,'$garage' ,'$room',' $lot','$ye arbuilt',' $levels',' $fireplace ','$centra lair','$zo ned','$gas ','$forced air','$sch ooldistric t','$eleme ntary','$m iddle','$h igh','$cou nty','$ext erior','$p roperty',' $style','$ parking',' $phone','$ email','$d escription ')";
}
// run SQL against the DB
$result = mysql_query($sql);
echo "Record updated/edited!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM home WHERE housecode=$housecode";
$result = mysql_query($sql);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$housecode) {
// print the list if there is not editing
$result = mysql_query("SELECT * FROM home",$db);
while ($myrow = mysql_fetch_array($result) ) {
printf("<a href=\"%s?housecode=%s\">% s, %s, %s %s</a> \n", $PHP_SELF, $myrow["housecode"], $myrow["address"], $myrow["city"], $myrow["state"] $myrow["zip"]);
printf("<a href=\"%s?housecode=%s&del ete=yes\"> (DELETE)</ a><br>", $PHP_SELF, $myrow["housecode"]);
}
}
?>
<P>
<a href="<?php echo $PHP_SELF?>">ADD A RECORD</a>
<P>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($housecode) {
// editing so select a record
$sql = "SELECT * FROM home WHERE housecode=$housecode";;
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result) ;
$housecode = $myrow["housecode"];
$address = $myrow["address"];
$city = $myrow["city"];
$state = $myrow["state"];
$zipcode = $myrow["zip"];
// print the id for editing
?>
<input type=hidden name="housecode" value="<?php echo $housecode ?>">
<?php
}
?>
House Code: <input type="Text" name="housecode" value="<?php echo $housecode ?>"><br>
Address: <input type="Text" name="address" value="<?php echo $address ?>"><br>
City: <input type="Text" name="city" value="<?php echo $city ?>"><br>
State: <input type="Text" name="state" value="<?php echo $state ?>"><br>
Zip Code: <input type="Text" name="zipcode" value="<?php echo $zip ?>"><br>
Price: <input type="Text" name="price" value="<?php echo $price ?>"><br><br />
No. of Beds: <input type="Text" name="bed" value="<?php echo $beds ?>"><br>
No. of Bath: <input type="Text" name="bath" value="<?php echo $bath ?>"><br>
No. of Garages: <input type="Text" name="garage" value="<?php echo $garage ?>"><br>
No. of Rooms: <input type="Text" name="room" value="<?php echo $rooms ?>"><br>
Range of Lot: <input type="Text" name="lot" value="<?php echo $lotrange ?>"><br>
Year House was Built: <input type="Text" name="yearbuilt" value="<?php echo $built ?>"><br><br />
No. of Levels: <input type="Text" name="levels" value="<?php echo $levels ?>"><br>
No. of Fireplaces: <input type="Text" name="fireplace" value="<?php echo $fireplace ?>"><br><br />
Central Air <input type="checkbox" name="centralair" value="<?php echo $centralair ?>" /> Zoned <input type="checkbox" name="zoned" value="<?php echo $zoned ?>" /> Gas <input type="checkbox" name="gas" value="<?php echo $gas ?>" /> Forced Air <input type="checkbox" name="forcedair" value="<?php echo $forcedair ?>" /><br /><br />
School District: <input type="Text" name="schooldistrict" value="<?php echo $schooldistrict ?>"><br />
Elementary School: <input type="Text" name="elementary" value="<?php echo $elementaryschool ?>"><br />
Middle School: <input type="Text" name="middle" value="<?php echo $middleschool ?>"><br />
High School: <input type="Text" name="high" value="<?php echo $highschool ?>"><br />
County: <input type="Text" name="county" value="<?php echo $county ?>"><br />
Exterior: <input type="Text" name="exterior" value="<?php echo $exterior ?>"><br />
Property Type: <input type="Text" name="property" value="<?php echo $propertytype ?>"><br />
Style: <input type="Text" name="style" value="<?php echo $style ?>"><br />
Parking: <input type="Text" name="parking" value="<?php echo $parking ?>"><br /><br />
Contact Information - Phone: <input type="Text" name="phone" value="<?php echo $contactphone ?>"><br />
Contact Information - Email: <input type="Text" name="email" value="<?php echo $contactemail ?>"><br /><br />
Description: <textarea name="description" cols="60" rows="12" wrap="hard"><?php echo $description ?></textarea>
<br /><br /><br />
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
?>
</body>
</html>
I tried running the page but I keep getting this error:
Parse error: parse error, unexpected T_VARIABLE in /home/i24-7hom/public_html /admin/ind ex.php on line 30
Can anyone help me?
<html>
<body>
<?php
$db = mysql_connect("localhost",
mysql_select_db("i24-7hom_
if ($submit) {
// here if no ID then adding else we're editing
if ($housecode) {
$sql = "UPDATE home SET address='$address',city='$
} else {
$sql = "INSERT INTO home (housecode,address,city,st
}
// run SQL against the DB
$result = mysql_query($sql);
echo "Record updated/edited!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM home WHERE housecode=$housecode";
$result = mysql_query($sql);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$housecode) {
// print the list if there is not editing
$result = mysql_query("SELECT * FROM home",$db);
while ($myrow = mysql_fetch_array($result)
printf("<a href=\"%s?housecode=%s\">%
printf("<a href=\"%s?housecode=%s&del
}
}
?>
<P>
<a href="<?php echo $PHP_SELF?>">ADD A RECORD</a>
<P>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($housecode) {
// editing so select a record
$sql = "SELECT * FROM home WHERE housecode=$housecode";;
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result)
$housecode = $myrow["housecode"];
$address = $myrow["address"];
$city = $myrow["city"];
$state = $myrow["state"];
$zipcode = $myrow["zip"];
// print the id for editing
?>
<input type=hidden name="housecode" value="<?php echo $housecode ?>">
<?php
}
?>
House Code: <input type="Text" name="housecode" value="<?php echo $housecode ?>"><br>
Address: <input type="Text" name="address" value="<?php echo $address ?>"><br>
City: <input type="Text" name="city" value="<?php echo $city ?>"><br>
State: <input type="Text" name="state" value="<?php echo $state ?>"><br>
Zip Code: <input type="Text" name="zipcode" value="<?php echo $zip ?>"><br>
Price: <input type="Text" name="price" value="<?php echo $price ?>"><br><br />
No. of Beds: <input type="Text" name="bed" value="<?php echo $beds ?>"><br>
No. of Bath: <input type="Text" name="bath" value="<?php echo $bath ?>"><br>
No. of Garages: <input type="Text" name="garage" value="<?php echo $garage ?>"><br>
No. of Rooms: <input type="Text" name="room" value="<?php echo $rooms ?>"><br>
Range of Lot: <input type="Text" name="lot" value="<?php echo $lotrange ?>"><br>
Year House was Built: <input type="Text" name="yearbuilt" value="<?php echo $built ?>"><br><br />
No. of Levels: <input type="Text" name="levels" value="<?php echo $levels ?>"><br>
No. of Fireplaces: <input type="Text" name="fireplace" value="<?php echo $fireplace ?>"><br><br />
Central Air <input type="checkbox" name="centralair" value="<?php echo $centralair ?>" /> Zoned <input type="checkbox" name="zoned" value="<?php echo $zoned ?>" /> Gas <input type="checkbox" name="gas" value="<?php echo $gas ?>" /> Forced Air <input type="checkbox" name="forcedair" value="<?php echo $forcedair ?>" /><br /><br />
School District: <input type="Text" name="schooldistrict" value="<?php echo $schooldistrict ?>"><br />
Elementary School: <input type="Text" name="elementary" value="<?php echo $elementaryschool ?>"><br />
Middle School: <input type="Text" name="middle" value="<?php echo $middleschool ?>"><br />
High School: <input type="Text" name="high" value="<?php echo $highschool ?>"><br />
County: <input type="Text" name="county" value="<?php echo $county ?>"><br />
Exterior: <input type="Text" name="exterior" value="<?php echo $exterior ?>"><br />
Property Type: <input type="Text" name="property" value="<?php echo $propertytype ?>"><br />
Style: <input type="Text" name="style" value="<?php echo $style ?>"><br />
Parking: <input type="Text" name="parking" value="<?php echo $parking ?>"><br /><br />
Contact Information - Phone: <input type="Text" name="phone" value="<?php echo $contactphone ?>"><br />
Contact Information - Email: <input type="Text" name="email" value="<?php echo $contactemail ?>"><br /><br />
Description: <textarea name="description" cols="60" rows="12" wrap="hard"><?php echo $description ?></textarea>
<br /><br /><br />
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
?>
</body>
</html>
I tried running the page but I keep getting this error:
Parse error: parse error, unexpected T_VARIABLE in /home/i24-7hom/public_html
Can anyone help me?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change:
printf("<a href=\"%s?housecode=%s\">%
To:
printf("<a href=\"%s?housecode=%s\">%