Update Query Question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Harlequin
Forum Commoner
Posts: 51
Joined: Tue Sep 21, 2004 10:51 am
Location: UK

Update Query Question

Post by Harlequin »

Morning all.

I have a fairly simple form that presents results from a table in text fields.

A user can insert new values and click a submit button. But for some reason the submission isn't working.

Here's what I have:

Code: Select all

echo "<form method='POST' action='Events_Updated.php?EventID=$result&#1111;EventID]'>";
echo "<input type='hidden' name='EventID value='$result&#1111;EventID]'>";
I won't bore you with the rest but on the submission page I have this:

Code: Select all

// Update Database:
$UpdateDatabase = "UPDATE events SET
EventTime	    = '" . $_POST&#1111;"EventTime"] .  "',
EventDate	    = '" . $_POST&#1111;"EventDate"] .  "',
EventBooked     =	'" . $_POST&#1111;"EventBooked"] .  "',
EventSpeaker    =	'" . $_POST&#1111;"EventSpeaker"] .  "'
WHERE EventID   = '" . $_POST&#1111;"EventID"] .  "'";
$Updated = mysql_query($UpdateDatabase) or die ("Error: " . mysql_error());
What am I missing...?
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

On your hidden field, you are missing a single quote after the name value. Try correcting that and see if it works.
Harlequin
Forum Commoner
Posts: 51
Joined: Tue Sep 21, 2004 10:51 am
Location: UK

Post by Harlequin »

Thanks Jean-Yves

Couldn't see the wood for the trees...!

If I want to use the old PHP_Self to keep users on that page should I be using GET instead of POST in the update query then...?
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

btw, why do you use both methods i mean your form action is
'Events_Updated.php?EventID=$result[EventID]'

and then you post it with hidden field, too..

it's not necessary i think..
Harlequin
Forum Commoner
Posts: 51
Joined: Tue Sep 21, 2004 10:51 am
Location: UK

Post by Harlequin »

Actually - you're right.

It's code I've been working on between other things so I guess some of the old stuff just kind of got left there.

Some of my older pages have more lines commented out than executed...!
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Harlequin wrote:Thanks Jean-Yves

Couldn't see the wood for the trees...!
Been there, done that - many times! Even with colour syntax-highlighting :D
If I want to use the old PHP_Self to keep users on that page should I be using GET instead of POST in the update query then...?

I'm not sure that I understand - why would you want the PHP_SELF as part of the query?

Or do you mean that you want to call the update and return to the page that has the form? I confess that I just use the form's name, but I think that you can use $HTTP_REFERER to get the name of the calling page. However, this does not always seem to work for me, and is open to hacking apparently since it can be spoofed (I think - not an expert on this!)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

HTTP_REFERER should rarely be used, now-a-days, it often doesn't exist, or can easily be erroneous. Remember, it is information coming from the user, and the user's inputs cannot be trusted, ever.
Post Reply