Jump to content


error in code for updating records

  • Please log in to reply
2 replies to this topic

#1 kikilahooch

  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 23 August 2006 - 05:20 PM

I'm trying to update records that are stored in my db on products. what I am doing is I am clicking on an image of a product to update. When I click on a product it brings me to my admin_update2.php page and passes in the value of shopName and prodId. I can see from the url that these values are being passed through ok. However I am getting an error saying

Parse error: parse error, unexpected $ in /home/c/ciaracousins/public_html/admin_update2.php on line 143

line 143 is just a blank line at the very bottom of my page. Any idea what is wrong with this??



$prodId = $_GET['prodId']; 

$sql = "select * from product where prodId = '$prodId'";

//$result = mysql_query($sql,$conn) or die(mysql_error()); 

if (isset($_POST['submittedUpdate'])) 
    $prodId         = mysql_real_escape_string(trim($_POST['prodId'])); 
    $sName          = mysql_real_escape_string(trim($_POST['shopName'])); 
    $dept           = mysql_real_escape_string(trim($_POST['dept'])); 
    $brand          = mysql_real_escape_string(trim($_POST['brand']));
    $type           = mysql_real_escape_string(trim($_POST['type'])); 
    $image          = mysql_real_escape_string(trim($_POST['image'])); 
    $price          = mysql_real_escape_string(trim($_POST['price'])); 

		$query2 = "UPDATE product SET prodName='$prodName', dept='$dept', brand='$brand', type='$type', image='$image', price='$price' WHERE prodId ='$prodId' and shopName='$shopName'";

$query = "SELECT * FROM product WHERE prodId = '$prodId'";

if ($result = mysql_query($query)) 
    $row = mysql_fetch_array($result, MYSQL_ASSOC) 
    <form action="admin_update2.php" method="post"> 
    <table align="center" cellspacing="0" cellpadding="5" bgcolor="#ffffff" border=1 bordercolor="#2696b8">

        <TR><TD align="left" bgcolor="#2696b8" width="30%"><FONT color="white"><B>Product Id: </B></FONT></TD> 
        <TD width="70%"><?php echo $row['prodId'] ?></TD></TR> 

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Shop Name:</B></FONT></TD> 
        <TD width="70%"><?php echo $row['shopName'] ?>"></TD></TR> 

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Product Name:</B></FONT></TD> 
        <TD><INPUT type="text" maxLength=45 size=45 name=name value="<?php echo $row['prodName'] ?>"></TD></TR> 

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Department:</B></FONT></TD> 
        <TD><INPUT type="text" maxLength=45 size=45 name="surname" value="<?php echo $row['dept'] ?>"></TD></TR> 

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Brand:</B></FONT></TD> 
        <TD><INPUT type="text" maxLength=45 size=45 name="address" value="<?php echo $row['brand'] ?>"></TD></TR> 

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Type:</B></FONT></TD> 
        <TD><INPUT type="text" maxLength=45 size=45 name="address2" value="<?php echo $row['type'] ?>"></TD></TR> 

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Image:</B></FONT></TD> 
        <TD><INPUT type="text" maxLength=45 size=45 name="county" value="<?php echo $row['image'] ?>"></TD></TR>

        <TR><TD align="right" bgcolor="#2696b8"><FONT color="white"><B>Price:</B></FONT></TD> 
        <TD><INPUT type="text" maxLength=45 size=45 name="county" value="<?php echo $row['price'] ?>"></TD></TR>

        <TD><CENTER><input name=submit type=submit value="UPDATE"> 
        <FONT color=navy></FONT></P></TD></TR> 

	<input type="hidden" name="prodId" value='.$prodId.'>
	<input type="hidden" name="submittedUpdate" value="TRUE"/></td></tr>



//line 143

#2 craygo

  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 23 August 2006 - 05:25 PM

You didn't close both of your if statements

you need another } at the end of your script


#3 kikilahooch

  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 23 August 2006 - 06:55 PM

Thanks Ray,

I am passing the values through into the admin_update2.php page from my admin_delete.php page using:

<td align="center"><a href="admin_update2.php?login=true&shopName='.$row['shopName'].'&prodId='.$row['prodId'].'"><img src="http://snet.wit.ie/~ciaracousins/clothes/' . $row['image'] . '"></a>

The user clicks on an image and it passes the values through to the next page, but when I do this it does not display the table to update the records. Any reason why its not displaying?? The values are being passed through ok

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users