|
Posted by noone on 02/23/06 18:47
Lag wrote:
> Having a problem updating my database from a web page, through a
> submission form. Can anyone help?
>
> ----THIS IS MY CODE IN update.php----(user, pass, and database are
> typed in directly, I changed them here for securiy reasons :) )
>
> <?php
>
> /*---CONNECT TO DATABASE---*/
>
> $conn = mysql_connect("localhost", "user", "pass") or
> die(mysql_error());
> mysql_select_db("database",$conn) or die(mysql_error());
>
> $event = $_GET["id"];
> $title=$_POST['title'];
> $date=$_POST['datetime'];
> $desc=$_POST['desc'];
>
> //---UPDATE ENTRY IN DATABASE---
> $query = "UPDATE 'calendar_events' SET 'event_title' = '$title',
> 'event_start' = '$date', 'event_shortdesc' = '$desc' WHERE 'id' =
> $event";
>
> //LIST ITEMS
> echo "$event $title $date $desc";
>
> mysql_query($query);
> echo "Record Updated";
> mysql_close();
>
> ?>
>
> -----------------------THIS IS THE
> OUTPUT-------------------------------------
> TEST changed 2006-02-22 06:00:00 TESTING EDITINGRecord Updated
> --------------------------------------------------------------------------------------------
> The original information was "TEST 2006-02-22 06:00:00 TESTING EDITING"
> I changed "TEST" to "TEST changed" in the submit form on a previous
> page.
>
> I included the echo to see if my information was truly getting passed,
> it is. I passed the id, title, event_start, and event_shortdesc from
> the previous page where the submission form is located. Why isn't my
> database entry (row) updating? Please help.
>
Why are you quoting the table names. This is VERY POOR programming
style and the database name (depending on database engine) Will
interpret tablea and 'tablea' as two different tables. Database entity
names are case insensitive.
As someone that has been around databases for a very long time, do not
quote anything but text columns in the database - and then you must in
order for it to work :).
[Back to original message]
|