I new to PHP, i'm trying to follow the demo at this page http://mkaz.com/ref/php/db/start.html but the manage_data (manage.php) and (manageedit.php) are not working I get:
arse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/www/sd.tom47.com/db/manageedit.php on line 76
these are the codes;
<?
$usr = "user";
$pwd = "password";
$db = "dbname";
$host = "localhost";
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
if ($task=="del") {
$SQL = " DELETE FROM links ";
$SQL = $SQL . " WHERE id = $id ";
mysql_db_query($db, $SQL, $cid);
}
?>
<HTML>
<HEAD>
<TITLE>Manage Links</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" >
<H1>Edit Links</H1>
<?
$SQL = " SELECT * FROM links ";
$retid = mysql_db_query($db, $SQL, $cid);
if (!$retid) { echo( mysql_error()); }
else {
echo ("<P><TABLE CELLPADDING=4>\n");
while ($row = mysql_fetch_array($retid)) {
$sitename = $row["sitename"];
$id = $row["id"];
echo ("<TR>");
echo ("<TD>$sitename</TD>\n");
echo ("<TD><A HREF=\"manageedit.php?id=$id\">Edit</A></TD>");
echo ("<TD><A HREF=\"manage.php?id=$id&task=del\">Delete</A></TD>");
echo ("</TR>");
}
echo ("</TABLE>");
}
?>
</BODY>
</HTML>
that page calls this one and here is that i get the error;
<?
$usr = "--username--";
$pwd = "--password--";
$db = "dbname";
$host = "localhost";
#connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print "Database Error: " . mysql_error(); }
?>
<html>
<head>
<title>Update Link</title>
</head>
<body bgcolor="#ffffff">
<h2>Update Link</h2>
<?
# processed when form is submitted back onto itself
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$id = $_POST["id"];
$category = addslashes($_POST["category"]);
$sitename = addslashes($_POST["sitename"]);
$siteurl = addslashes($_POST["siteurl"]);
$description = addslashes($_POST["description"]);
# setup SQL statement
$sql = " UPDATE links SET";
$sql .= " category = '$category', ";
$sql .= " sitename = '$sitename', ";
$sql .= " siteurl = '$siteurl', ";
$sql .= " description = '$description' ";
$sql .= " WHERE id = $id ";
$sql .= " LIMIT 1 ";
# execute SQL statement
$result = mysql_query($sql,$cid);
# check for errors
if (mysql_error()) { print "Database Error: $sql " . mysql_error(); }
print "<p><b>Link Updated</b></p>\n";
}
else { # display edit form (not post method)
$id = $_GET["id"];
# setup SQL statement to retrieve link that we want to edit
$sql = " SELECT * FROM links ";
$sql .= " WHERE id = $id ";
# execute SQL statement
$rs = mysql_query($sql,$cid);
# retrieve values
$row = mysql_fetch_array($rs);
$sitename = $row["sitename"];
$siteurl = $row["siteurl"];
$category = $row["category"];
$description = $row["description"];
?>
<form name="fa" action="manageedit.php" method="post">
<input type="hidden" name="id" value="<?=$id?>">
<table>
<tr><td><b>Category: </b> </td><td><input type="text" name="category" value="<?=$category?>" size=40></td></tr>
<tr><td><b>Site Name:</b> </td><td><input type="text" name="sitename" value="<?=$sitename?>" size=40></td></tr>
<tr><td><b>Site URL: </b> </td><td><input type="text" name="siteurl" value="<?=$siteurl?>" size=40></td></tr>
<tr><td valign=top><b>Description: </b> </td><td> <textarea name="description" rows=5 cols=40><?=$description"?></textarea></td></tr>
<tr><th colspan=2><p><input type="submit" value="update link"></p></th></tr>
</table>
</form>
<? } ?>
</body>
</html>
the conection with the database is OK, I'm able to insert data and see the data in mysql database.
Anyone can help me ? I'm frustrated.