Jump to content

error in code for updating records


kikilahooch

Recommended Posts

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??

[code]
<?php

include("db.php");

$prodId = $_GET['prodId'];

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

//db
//$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">
    <center>
    <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>

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


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

    </TABLE>
    </FORM>
    <?php
}

?>

</body>
</html>

//line 143[/code]
Link to comment
https://forums.phpfreaks.com/topic/18449-error-in-code-for-updating-records/
Share on other sites

Thanks Ray,

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

[code]
<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>
[/code]

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.