Update Problem
Posted: Fri Jun 20, 2003 8:12 am
Hey guys and gals,
Ok, I'm having trouble updating my database. Right now I'm getting the error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/html/updateForm.php on line 21
I had a problem getting a database selected with $id so I added some code and now I get the error. I'm not 100% sure how to fix this problem but I know it has something to do with the line I added . Here's the run down on what this page should do:
1 - updateForm.php - This page displays the contents of the database and puts and "Edit" link and the beggining of each record. When the user clicks on the link it brings them to update.php
2 - update.php - This page consists of text input boxes and one drop down box. So depending on which link the user clicks, it should display the contents of that record in the input boxes so the user can see what they are changing. Then they can click on update and update the database.
Here is my code:
UPDATEFORM.PHP
UPDATE.PHP
Any suggestions would be greatly appreciated and thanks in advance:
[Admin Edit: added tags][/color]
Ok, I'm having trouble updating my database. Right now I'm getting the error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/html/updateForm.php on line 21
I had a problem getting a database selected with $id so I added some code and now I get the error. I'm not 100% sure how to fix this problem but I know it has something to do with the line I added . Here's the run down on what this page should do:
1 - updateForm.php - This page displays the contents of the database and puts and "Edit" link and the beggining of each record. When the user clicks on the link it brings them to update.php
2 - update.php - This page consists of text input boxes and one drop down box. So depending on which link the user clicks, it should display the contents of that record in the input boxes so the user can see what they are changing. Then they can click on update and update the database.
Here is my code:
UPDATEFORM.PHP
Code: Select all
<?
include("header.inc");
include("details.inc");
?>
<H2>hoose a Record to Update</H2>
Enter a Record
Search Database
Create a New User<P><HR></CENTER><P>
<?
include("title.inc");
$query="SELECT * FROM assets ORDER BY location ASC";
$result=mysql_query($query);
mysql_close();
while ($rs = mysql_fetch_array($result)) {
print ("<TR ALIGN=CENTER><TD>Edit</TD><TD>" . $rs['itemName'] . "</TD><TD>" . $rs['serialNum'] . "</TD><TD>" . $rs['assetNum'] . "</TD><TD>" . $rs['location'] . "</TD><TD>" . $rs['description'] . "</TD><TD>" . $rs['entryDate'] . "</TD><TD>" . $rs['warranty'] . "</TD></TR>");
}
include("footer.inc");
?>Code: Select all
<?
include("header.inc");
?>
<H2>Update Database</H2><P><HR>
<P>
Enter a Record
Search Database
Create a New User<P><HR></CENTER><P>
<?
include("details.inc");
$asset = $_POST['asset'];
$name = $_POST['name'];
$location = $_POST['location'];
$description = $_POST['description'];
$warranty = $_POST['warranty'];
$serial = $_POST['serial'];
$id=$_GET['id'];
$query="SELECT * FROM assets WHERE id='$id'";
$result=mysql_query($query);
mysql_close();
print ($query);
mysql_query($query) or die (mysql_error());
if(isset($_POST['btnUpdate'])) {
$query = "UPDATE assets SET
serialNum = '$serial',
assetNum = '$asset',
itemName = '$name',
location = '$location',
description = '$description',
warranty = '$warranty'
WHERE id LIKE '$id'";
mysql_query($query) or die (mysql_error());
mysql_close();
}
?>
<form method="post" action="<?php echo $PHP_SELF; ?>">
<TABLE BORDER=1 WIDTH=40% ALIGN="CENTER">
<TR ALIGN=CENTER>
<TD>Item Name</TD><TD>
></TD>
</TR>
<TR ALIGN=CENTER>
<TD>Serial Number</TD><TD>></TD>
</TR>
<TR ALIGN=CENTER>
<TD>Asset Number</TD><TD>></TD>
</TR>
<TR ALIGN=CENTER>
<TD>Location</TD><TD><Select name="location" value="<? echo $rs['location'] ?>">
<OPTION>
<OPTION>Baie Verte
<OPTION>Botwood
<OPTION>Bishop Falls
<OPTION>Buchans
<OPTION>Carmanville
<OPTION>Centreville
<OPTION>Change Islands
<OPTION>Fogo Island
<OPTION>Gambo
<OPTION>Gander
<OPTION>Gaultois
<OPTION>Glenwood
<OPTION>Glovertown
<OPTION>Grand Falls
<OPTION>Greenspond
<OPTION>Harbour Breton
<OPTION>Hare Bay
<OPTION>Harry's Harbour
<OPTION>Hermitage
<OPTION>King's Point
<OPTION>La Scie
<OPTION>Lewisporte
<OPTION>Lumsden
<OPTION>Musgrave Harbour
<OPTION>Norris Arm
<OPTION>Point Leamington
<OPTION>Robert's Arm
<OPTION>Seal Cove
<OPTION>Springdale
<OPTION>St. Alban's
<OPTION>Summerford
<OPTION>Twillingate
<OPTION>Wesleyville
</SELECT></TD>
</TR>
<TR ALIGN=CENTER>
<TD>Description</TD><TD>></TD>
</TR>
<TR ALIGN=CENTER>
<TD>Warranty</TD><TD>></TD>
</TR>
</TABLE>
<CENTER>
</FORM></CENTER>
<?
include("footer.inc");
?>[Admin Edit: added
Code: Select all