Reputation: 2823
OK I have a insert statement works well a delete statement, is working. However the UPDATE is not been on it for well over a day now and can not see the problem, only thing I think it could be is the date time local field in MySQL, but it works on insert.
form
$Band_id = (int)$_GET['id'];
$result = mysql_query("SELECT * FROM bands where Band_id ='$Band_id'");
$row = mysql_fetch_array($result);
?>
<form method="post" action="ammenddetails.php">
<input type="hidden" name="id" value="<? echo "$row[Band_id]"?>">
<tr><td>Band Name</td></br>
<td><input type="text" name="Name" size="20" value="<? echo "$row[Name]"?>"></td></tr></br>
<tr><tr><td>Show Name</td></br>
<td><input type="text" name="show" size="20" value="<? echo "$row[show]"?>"></td></tr></br>
<tr><td>Venue</td></br>
<td><input type="text" name="Venue" size="20" value="<? echo "$row[Venue]"?>"></td></tr></br>
<tr><td>Category</td></br>
<td><input type="text" name="Category" size="20" value="<? echo "$row[Category]"?>"></td></tr></br>
<tr><td>Date and Time</td></br>
<td><input type="datetime-local" name="time" size="20" value="<? echo "$row[time]"?>"></td></tr></br>
<tr><td>Price</td></br>
<td><input type="number" name="price" size="20" value="<? echo "$row[price]"?>"></td></tr></br>
<tr><td>Stock</td></br>
<td><input type="number" name="Stock" size="20" value="<? echo "$row[Stock]"?>"></td></tr></br>
<tr><td>Infomation</td></br>
<?php echo "<td><textarea name= 'infomation' cols=\"50\" rows=\"8\" >" .$row['infomation']. "</textarea></td>";?></tr></br>
<tr><input type="submit"name="submit value" value="Update"></td>
</tr>
</form>
ammenddetails.php
<?php
require 'core/init.php';
$Name = mysql_real_escape_string($_POST["Name"]);
$show = mysql_real_escape_string($_POST["show"]);
$Venue = mysql_real_escape_string($_POST["Venue"]);
$Category = mysql_real_escape_string($_POST["Category"]);
$price = mysql_real_escape_string($_POST["price"]);
$Stock = mysql_real_escape_string($_POST["Stock"]);
$time = mysql_real_escape_string($_POST["time"]);
$infomation = mysql_real_escape_string($_POST["infomation"]);
$Band_id = (int)$_POST['id'];
$result = mysql_query("UPDATE `bands`
SET `Name`=`$Name`,
`show`=`$show`,
`Venue`=`$Venue`,
`Category`=`$Category`,
`price`=`$price`,
`Stock`=`$Stock`,
`time`=`$time`,
`infomation`=`$infomation`
WHERE
`Band_id`=`$Band_id`");
echo "UPDATE `bands`
SET `Name`=`$Name`,
`show`=`$show`,
`Venue`=`$Venue`,
`Category`=`$Category`,
`price`=`$price`,
`Stock`=`$Stock`,
`time`=`$time`,
`infomation`=`$infomation`
WHERE
`Band_id`=`$Band_id`"
// header("location:admin.php");
?>
the echo on the query shows up as:
UPDATE `bands` SET `Name`=`Coldplay`, `show`=`Time of you life`, `Venue`=`London Wembley `, `Category`=`Rock`, `price`=`2`, `Stock`=`20`, `time`=`2014-01-23T01:59`, `infomation`=`info here test` WHERE `Band_id`=`3`
have tried out suggestion query now outputs:
UPDATE `bands` SET SET `Name`='Killers', `show`='Big Time High', `Venue`='London Apolo', `Category`='Rock', `price`='45', `Stock`='75', `time`='', `infomation`='BLOB values are trea' WHERE `Band_id`='1'
so the query is getting correct data just not updating the bd
Upvotes: 0
Views: 253
Reputation: 476
This is your problem.
SET `Name`=`$Name`,
You use ` to define fields, but for variables you need to use '
e.g.
SET `Name`='$Name',
....
a even better way is this:
SET `Name`='{$Name}',
....
try that and let me know! :)
Upvotes: 1