Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts

    Cannot get data into database

    I hope I have put this post in the right section.
    I cannot get data into my database
    This is the script that should update the database:
    PHP Code:
    $qry "UPDATE " $vars["fr table directory"] . " SET club_title='$club_title',club_name='$club_name',club_type='$club_type',club_address='$club_address',club_contact='$club_contact',club_details='$club_details',club_details2='$club_details2',club_dance_floor='$club_dance_floor',club_open='$club_open',club_admission='$club_admission',background_colour='$background_colour',background_image='$background_image',text_colour='$text_colour',header_colour='$header_colour' WHERE club_code='$club_code'";

        if(!(
    $results mysqli_query($link$qry ))){
            
    displayErrMsg(sprintf("Error in executing %s query"$qry));
            
    displayErrMsg(sprintf("error:%d %s"mysqli_errno($link), mysqli_error($link)));
            exit();
        }
            
    header ('Location:' .$input_page);
        } 
    I have put a trap in the script:
    PHP Code:
    var_dump($_GET); exit; 
    and this is the result:
    Code:
    array(15) { ["club_title"]=> string(38) "The Ranch House Country & Western club" ["club_name"]=> string(16) "The John Doe CWC" ["club_type"]=> string(24) "Country and Western Club" ["club_address"]=> string(0) "" ["club_details2"]=> string(0) "" ["club_dance_floor"]=> string(3) "yes" ["club_contact"]=> string(0) "" ["club_open"]=> string(0) "" ["club_admission"]=> string(0) "" ["club_details"]=> string(0) "" ["background_colour"]=> string(7) "#ffffff" ["background_image"]=> string(16) "multi_colour.jpg" ["text_colour"]=> string(7) "#990000" ["header_colour"]=> string(7) "#6633cc" ["action"]=> string(3) "add" }
    Can anybody see the problem? I have been working on this practically all day.

    Thanks,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,519
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Let's just look at one part ...

    club_title='$club_title'

    How does $_GET['club_title'] become $club_title ?

    Can you show us the entire script? Because we must not be seeing it all.

  • Users who have thanked mlseim for this post:

    countrydj (02-27-2013)

  • #3
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    in your output you have no club code so it doesn't know what to update
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • Users who have thanked Arcticwarrio for this post:

    countrydj (02-27-2013)

  • #4
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arcticwarrio View Post
    in your output you have no club code so it doesn't know what to update
    Hi Guys...
    Thank you very much for being so helpful.

    I can't believe that I've been such a 'dick head' !!!!
    I couldn't see the wood for the trees.
    I completely missed:
    PHP Code:
    WHERE club_code='$club_code'"; 
    I have no excuse. I wish I had.

    $club_code is defined at the top of the script: $club_code = "fr1195"; which is generated from: $club_code = "##[club_code]##";
    from:
    PHP Code:
        //ADD CLUB CODE TO NEW CLUB INPUT FILE
            
    $file_contents file_get_contents($new_addclub);
            
    $file_contents str_replace("##[new_addclub]##","$new_addclub",$file_contents);
            
    $file_contents str_replace("##[club_code]##","$club_code",$file_contents);
            
    file_put_contents($new_addclub,$file_contents); 
    Thank you for again for being so helpful. You prompted me towards the right direction.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #5
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    Let's just look at one part ...

    club_title='$club_title'

    How does $_GET['club_title'] become $club_title ?

    Can you show us the entire script? Because we must not be seeing it all.
    I have a very simple form, which is a double opt-in system for verification, for the user to fill in. When the user clicks on the verification link in their email, they are presented with a Verification Success page which includes a link to their individual input form. This is the basis for creating the first entry in the database.
    After the first entry, the user can UPDATE their database entry with their details
    This is pulled from the database, along with all the other variables:
    $club_title = $_GET['club_title'];

    Thank you once again for coming to my rescue.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,519
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Why are you using $_GET? Can't you use $_POST?

  • #7
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    its from an email link
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #8
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    Why are you using $_GET? Can't you use $_POST?
    Hi mlseim...

    I don't know is the simple answer.
    The truth is that I don't know when to use POST or GET.

    I would appreciate you advising me.

    Thank you,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #9
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    POST hides all the data sent between pages where GET shows it in the address bar
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #10
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arcticwarrio View Post
    POST hides all the data sent between pages where GET shows it in the address bar
    Thanks for your very quick reply.
    1. Is this the only advantage ???
    2. Does it matter ???

    Regards,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #11
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    POST is the preferred option,
    however you cant use POST for links

    POST is more secure, you wouldn't send a password as GET,
    also any hidden form fields will be shown in GET too.

    GET can be altered by the user too
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #12
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arcticwarrio View Post
    POST is the preferred option,
    however you cant use POST for links

    POST is more secure, you wouldn't send a password as GET,
    also any hidden form fields will be shown in GET too.

    GET can be altered by the user too
    Thank you Arcticwarrio..
    This explains it better for me.

    One last point: can you give me an example of what you mean "you cant use POST for links".

    I really do wish I understood things better.

    Thanks,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #13
    Regular Coder Arcticwarrio's Avatar
    Join Date
    May 2012
    Location
    UK
    Posts
    723
    Thanks
    20
    Thanked 84 Times in 84 Posts
    like the address for this thread

    http://codingforums.com/php/288340-cannot-get-data-into-database.html

    the php for querying the database would be

    PHP Code:
    SELECT FROM posts WHERE thread $_GET['t'
    ?t=288340 where t is the variable and 288340 is the value

    when posting a form the variables are all hidden therefor cant be in the address bar

    Code:
    http://www.codingforums.com/showthread.php?t=288340
    There are 10 types of people on CodingForums,
    Those who understand Binary and those who dont.
    Get Cloud Hosting now from only£59 / month

  • #14
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,519
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Can you show us an example of what one of the links looks like when a person gets an email?

    Maybe that will shed some light on this.

    I missed the part about a confirmation link from an email. But I want to see what that confirmation link looks like.

  • #15
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Hi Guys...
    Thank you very much for helping me.
    In order to let you know what is happening, here is a link to the index page:

    http://www.countrymusic.org.uk/clubs...dmin/index.php

    Here is the resulting email:
    Code:
    Please DO NOT reply to this email. It is an unattended mailbox.
    
    To validate your email address, please click the following link:
    
    http://countrymusic.org.uk/clubs/fr_clubs/fr_admin/register-exec.php?your_phone=07989115251&your_email=j@in-uk.co.uk&status=1&club_name=Ranch_House&action=add&your_name=John_Doe&passwd=asda1234&m=3c4d583d63292f70aba39f853fa7a9e8
    This link then returns a page with a link to open an input page for the user, and also creates the first entry into the database, using 'club_code' as the reference for all other updates.

    This is the page that the above link created:

    http://www.countrymusic.org.uk/clubs...add_fr1208.php

    If you do take a look at this, you will see that there is very little information.
    The user can then fill in the boxes and update the database.
    After updating the database, the form is returned with all the information filled in that is contained in the database.
    I did it this way because I don't have to create a special update form.

    This is as far as I have got.
    The Review Web Page and Add Dates buttons don't work properly because I haven't managed to get round to coding them to automatically be created with the correct information to display the web page properly.

    If you want to test it for yourselves, please go ahead. It is still in production so you can't do any harm.
    Also, this type of project is a first for me, so any advise will be welcome.

    BTW, I am doing this out of interest, and because I enjoy getting absolutely frustrated doing it. Although I hope the script will be used, I won't receive any reward at all for doing it. Most of the things on my web site are FREE.

    Thanks.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •