Jump to content

Error Updating Record:


colleyboy

Recommended Posts

I am getting this error when updating a record (through a form)

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/barryottley/updates.php on line 62

 

This is updates.php

 

<?php

mysql_connect("localhost", "wormste1_barry", "barry") or die(mysql_error());
mysql_select_db("wormste1_barry") or die(mysql_error());

$carname = mysql_real_escape_string(trim($_POST['CarName']));
$cartitle = mysql_real_escape_string(trim($_POST['CarTitle']));
$carprice = mysql_real_escape_string(trim($_POST['CarPrice']));
$carmiles = mysql_real_escape_string(trim($_POST['CarMiles']));
$cardesc = mysql_real_escape_string(trim($_POST['CarDescription']));




mysql_query("UPDATE cars WHERE id='.intval ($_GET['id']).' LIMIT 1 
(CarName, CarTitle, CarPrice, CarMiles, CarDescription, photo) VALUES('$carname', '$cartitle', '$carprice', '$carmiles', '$cardesc' ) ") 
or die(mysql_error());  


echo "The vehicle data has been updated!";

?>

 

the updates.php actually processes the update.

 

the form page is edit.php:

 

<CENTER><B>Update a Vehicle</B></CENTER>
<BR>

<?php
$what_id=$_GET['id'];
$query="SELECT * FROM cars WHERE id = '$what_id'";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)) {

$carname = $row['CarName'];

$cartitle = $row['CarTitle'];

$carprice = $row['CarPrice'];

$carmiles = $row['CarMiles'];

$cardesc = $row['CarDescription'];
}
?>
<form action="updates.php" method="post">
<CENTER>Vehicle Name:</CENTER> <br><CENTER><input type="text" name="CarName" value="<?php echo $carname; ?>"></CENTER><br>
<CENTER>Vehicle Type:</CENTER><br><CENTER><input type="text" name="CarTitle" value="<?php echo $cartitle; ?>"></CENTER><br>
<CENTER>Vehicle Price:</CENTER><br><CENTER><input type="text" name="CarPrice" value="<?php echo $carprice; ?>"></CENTER><br>
<CENTER>Vehicle Mileage:</CENTER><br><CENTER><input type="text" name="CarMiles" value="<?php echo $carmiles; ?>"></CENTER><br>
<CENTER>Vehicle Description:</CENTER><br><CENTER><input type="text" name="CarDescription" value="<?php echo $cardesc; ?>"></CENTER><br>
<CENTER>Vehicle Description:</CENTER><br>
<CENTER><textarea name="CarDescription" rows="10" cols="30" value="<?php echo nl2br($cardesc); ?>"></textarea></CENTER><br>
<CENTER><input type="Submit"></CENTER>
</form>

 

Any idea for the error.  I think it could be because the UPDATE tag syntax is wrong.

 

Help would be great!!!

Link to comment
Share on other sites

add this to your form

 

<input type="hidden" name="what_id" value="<?PHP echo $what_id; ?>">

 

 

then change this...

mysql_query("UPDATE cars WHERE id='.intval ($_GET['id']).' LIMIT 1 
(CarName, CarTitle, CarPrice, CarMiles, CarDescription, photo) VALUES('$carname', '$cartitle', '$carprice', '$carmiles', '$cardesc' ) ") 
or die(mysql_error()); 

 

to this...

 

$what_id=$_POST['what_id'];

mysql_query("UPDATE cars CarName='$carname', CarTitle='$cartitle', CarPrice='$carprice', CarMiles='$carmiles', CarDescription='$cardesc' WHERE id = '$what_id'") or die(mysql_error()); 

Link to comment
Share on other sites

litebearer...

 

have mde the changed but still get this error:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='Ford Cortina', CarTitle='Saloon', CarPrice='£1250', CarMiles='99999', CarDescr' at line 1

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.