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.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question about Insert Query = VERY URGENT

    There is an existing form where a user is asked if they would like to receive emails alerts and presently it is a radio button and it has 2 options Yes & No. By default Yes is selected. So in this case the data is captured.

    Now we would like to change this where the same radio buttons would appear however none of them would be checked by default, so its upto the user to select Yes or No. In this case if the radio buttons are left blank then an error occurs from the php file. I have a code to check if the radio button was unchecked so that there would be no errors. the code is =

    $receiveemails = empty($_POST['receiveemails']);
    if($receiveemails) $receiveemails = "Blank checkbox"; else $receiveemails = $_POST["receiveemails"];

    As of now the way the code is written is as follows which was written by another person which is =

    insert into table(a,b,c) values($a,$b,%s, %s)

    GetSQLValueString($_POST['specialOffers'], "text"),

    MY QUESTION IS

    1. what is %s in the insert statement actually doing

    2. what is GetSQLValueString($_POST['specialOffers'], "text") code actually doing

    Please advice

    a) what this code is doing as if i implement my code this might have a drastic impact on how data is inserted into the table in mysql. As the "specialOffers" appears in lot many places in the php file.
    b) what i can do with the existing code so that Even if a user does not select the radio button data should still be inserted into the table.

    Even with a checkbox if it is left blank the same error happens just like radio button.

    Any help will be greatly appreciated.

  • #2
    New Coder
    Join Date
    Oct 2007
    Posts
    84
    Thanks
    0
    Thanked 8 Times in 8 Posts
    There are more values than there are columns.
    None of the variables are wrapped in quotes. Are they all ints?

    getsqlvaluestring is a function that is declared somewhere else. From googling it looks like it is a ready made that was created to prevent SQL injection.

    As for your radio buttons, why not echo the value of $_POST['receiveemails'] and see what that gets you. I haven't worked with radio buttons in a while so I'm a little rusty there.


  •  

    Posting Permissions

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