Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | PHP again!

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > General IT Discussion

PHP again!
Reply
 
Thread Tools
Old 08-06-2006, 19:05   #1
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
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!
Strzelecki is offline   Reply With Quote
Advertisement
Old 08-06-2006, 23:21   #2
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
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.
greencreeper is offline   Reply With Quote
Old 08-06-2006, 23:36   #3
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
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.
Strzelecki is offline   Reply With Quote
Old 08-06-2006, 23:39   #4
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
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.
greencreeper is offline   Reply With Quote
Old 08-06-2006, 23:42   #5
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
Re: PHP again!

something like
PHP Code:
$result = mysql_query($sql); 
?
Strzelecki is offline   Reply With Quote
Old 08-06-2006, 23:46   #6
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
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
greencreeper is offline   Reply With Quote
Old 08-06-2006, 23:53   #7
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
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.
Strzelecki is offline   Reply With Quote
Old 08-06-2006, 23:56   #8
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
Re: PHP again!

Now getting
greencreeper is offline   Reply With Quote
Old 08-06-2006, 23:59   #9
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
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.
Strzelecki is offline   Reply With Quote
Old 09-06-2006, 00:23   #10
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
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?
greencreeper is offline   Reply With Quote
Old 09-06-2006, 00:31   #11
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
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.
Strzelecki is offline   Reply With Quote
Old 09-06-2006, 00:33   #12
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
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.
greencreeper is offline   Reply With Quote
Old 09-06-2006, 00:36   #13
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
Re: PHP again!

ok, i really appriciate your help! I'll crack this somehow, usually pretty good with PHP but this is so simple!
Strzelecki is offline   Reply With Quote
Old 09-06-2006, 00:38   #14
greencreeper
Inactive
 
Join Date: Nov 2003
Location: Leeds - the dog house
Age: 49
Services: Email me for a current price list
Posts: 8,270
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
greencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny stargreencreeper has a nice shiny star
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...
greencreeper is offline   Reply With Quote
Old 09-06-2006, 00:42   #15
Strzelecki
Inactive
 
Join Date: Jan 2004
Location: Essex
Age: 43
Services: 80/20Mbps FTTC on Freeola
Posts: 871
Strzelecki has reached the bronze age
Strzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze ageStrzelecki has reached the bronze age
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!
Strzelecki is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 17:57.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum