08-06-2006, 19:05
|
#1
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
PHP again!
I'm hoping someone can help, there's a really obvious problem here but I've stared at it for too long and can't see it! Here the code:
http://www.strzelecki.co.uk/rsvp.phps
It's an RSVP script for my wedding website that pull the guests details from a database and allows them to amend them and tell me whether they are coming and then updates the database with this info, normally simple, but it refuses to do the update, I think I've done the loops wrong but a fresh pair of eyes will be able to spot that!
For reference the array(s) produced to update the data seem ok
Code:
Array
(
[last_name_upd] => Strzelecki
[first_name_upd] => Array
(
[0] => Andy
[1] => Sue
[2] => Rob
[3] => Chris
)
[id_upd] => Array
(
[0] => 7
[1] => 8
[2] => 9
[3] => 10
)
[surname_id] => Array
(
[0] => 2
[1] => 2
[2] => 2
[3] => 2
)
[address_upd] => An Address
[postcode_upd] => SA62 2PW
[telephone_number_upd] => 01234567891
[email_address_upd] => a@a.com
[song_artist] => example
[song_name] => example name
[updateinvite] => Submit
)
Cheers!
|
|
|
08-06-2006, 23:21
|
#2
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
PHP Code:
if(isset($last_name_upd)) {
update_details();
}
else {
//print something
}
Replace the "print something" with a line of HTML or something similar. Suspect that this is the point of failure, though I'm struggling to follow the variables in my head.
---------- Post added at 23:21 ---------- Previous post was at 23:15 ----------
I would have used frm and db prefixes for the form and database variables, to avoid the possibility of confusion, which if the else above is true, would be most likely what has happened.
|
|
|
08-06-2006, 23:36
|
#3
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!
Ok I'll give that a try! Although I think if it was that it wouldn't print out the array content as this comes afterwards.
|
|
|
08-06-2006, 23:39
|
#4
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
Hmmm  Is there not a built-in result variable  Trying to recall from the last time I wrote PHP - pretty certain you can check the result of the last SQL statement executed.
|
|
|
08-06-2006, 23:42
|
#5
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!
something like
PHP Code:
$result = mysql_query($sql);
?
|
|
|
08-06-2006, 23:46
|
#6
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
Yeah - looks right. Should also be an error variable I think.
I can always read code, even if I can't write it. It's been a few years since I wrote in PHP - wrote an ecommerce website for a project at Uni. Condom shop. Caused a bit of a stir
|
|
|
08-06-2006, 23:53
|
#7
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!

Well I think I see a problem, now getting:
Code:
Ian4Array
(
[last_name_upd] => surname
[first_name_upd] => Array
(
[0] => Ian
[1] => Sue
[2] => Jo
)
[id_upd] => Array
(
[0] => 4
[1] => 5
[2] => 6
)
[surname_id] => Array
(
[0] => 1
[1] => 1
[2] => 1
)
[address_upd] => an address
[postcode_upd] => a postcode
[telephone_number_upd] => 01234567891
[email_address_upd] => a@a.com
[song_artist] =>
[song_name] =>
[updateinvite] => Submit
)
Sue5Array
(
[last_name_upd] => surname
[first_name_upd] => Array
(
[0] => Ian
[1] => Sue
[2] => Jo
)
[id_upd] => Array
(
[0] => 4
[1] => 5
[2] => 6
)
[surname_id] => Array
(
[0] => 1
[1] => 1
[2] => 1
)
[address_upd] => an address
[postcode_upd] => a postcode
[telephone_number_upd] => 01234567891
[email_address_upd] => a@a.com
[song_artist] =>
[song_name] =>
[updateinvite] => Submit
)
Jo6Array
(
[last_name_upd] => surname
[first_name_upd] => Array
(
[0] => Ian
[1] => Sue
[2] => Jo
)
[id_upd] => Array
(
[0] => 4
[1] => 5
[2] => 6
)
[surname_id] => Array
(
[0] => 1
[1] => 1
[2] => 1
)
[address_upd] => an address
[postcode_upd] => a postcode
[telephone_number_upd] => 01234567891
[email_address_upd] => a@a.com
[song_artist] =>
[song_name] =>
[updateinvite] => Submit
)
The update condition is right, I can get it to print out each first name together with the relevant ID and all the variables to do the update are correct but now I'm not sure what is wrong with that output.
|
|
|
08-06-2006, 23:56
|
#8
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
Now getting
|
|
|
08-06-2006, 23:59
|
#9
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!
Well
PHP Code:
<pre><?php //testing output from form print_r($_POST); ?></pre>
will print out what is stored in the $_POST array (which is shown above) after the user had sumitted their updated info, it's from this that I want to do the update.
|
|
|
09-06-2006, 00:23
|
#10
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
Array output looks ok to me  Is the connection being closed at the end of the script, once all the updates are done?
|
|
|
09-06-2006, 00:31
|
#11
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!
Yeah tried
PHP Code:
mysql_close($rsvp);
, no luck. If I get it to echo all the variables I want to do the update with they all print out ok as well.
and it not having problems pulling the database up twice, just tried
PHP Code:
mysql_select_db($database_rsvp, $rsvp) or die ('Error, cannot select mysql database');
just before the update.
|
|
|
09-06-2006, 00:33
|
#12
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
If the data is all there and the query is definitely being execute, then I haven't a clue  One of the PHP gurus on here may have an idea tomorrow - when they're awake.
|
|
|
09-06-2006, 00:36
|
#13
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!
ok, i really appriciate your help! I'll crack this somehow, usually pretty good with PHP but this is so simple!
|
|
|
09-06-2006, 00:38
|
#14
|
|
Inactive
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
|
Re: PHP again!
You do know for certain that it's not doing the update - if you view the database outside of PHP, it's not got the data...
|
|
|
09-06-2006, 00:42
|
#15
|
|
Inactive
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
|
Re: PHP again!
correct. No update whatso ever. Although you have just given me an idea, swap it for a delete and see if that works!
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 17:52.
|