Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error in code for updating records

    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

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Nearly always this means you haven't enclosed code blocks properly with the {} brackets. In your case, you have two "if" blocks, but only one closing } bracket.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •