List/Menu (multiple selected)  insert into MySQL

I have been building a feedback form and I am running into a
issue that when I place a list/menu that allows multiple selections
when I submit my form in my MySQL database it collected the
information but only on the last multiple selection.
For example, this is what my list/menu looks like.
<select name="occasion" size="5" multiple="MULTIPLE"
id="occasion">
<option value="Spur of the moment,">Spur of the
moment</option>
<option value="Family dinner">Family
dinner</option>
<option value="Special occasion (i.e.
birthday)">Special occasion (i.e. birthday)</option>
<option value="Office get together">Office get
together</option>
<option value="Romantic dinner">Romantic
dinner</option>
<option value="Night out with friends">Night out with
friends</option>
<option value="Business meeting">Business
meeting</option>
<option value="Other">Other</option>
</select>
And my MySQL database I have it set up as...
Field Type
occasion mediumtext
I do not know why I cannot have more than one selection
inputed into my field, what must I do to correct this? Everything
works perfectly expect the multi selected list/menu. I want to
place all that is selected in the list/menu in that one database
field called occasion.

.oO(MikeL7)
>>You should also test with isset() and is_array() if
$_POST['occasion']
>>is available at all and of the expected type. The
code above will also
>>throw a notice if $insert_string is not initialized
before the loop.
>
> I use both isset and is_array in my code, When you say
notice, you dont mean
>a script stoppiong error?
Nope. An E_NOTICE error won't terminate the script, but
shouldn't happen
nevertheless. While developing, the error_reporting directive
should be
set to E_ALL|E_STRICT and _all_ reported problems should be
solved. It's
not only better coding style, but also helps to prevent real
errors. In
this particular case it was just a guess, because it was only
a part of
the code. But using an uninitialized variable with a '.='
operator for
example would lead to a notice, which should be fixed.
>>But of course this is a really bad DB design, as it
already violates the
>> first normal form (1NF). Just some ideas for queries
that might come to
>> mind, but would be really hard to do with such a
comma-separated list:
>
> A better table design would be to have column for |
list_ID | user_ID |
>song_ID | and do a insert for each song selected.
Yes, something like that.
>Thanks for the input, i like escaping the variables from
a string as they
>stand out more in code view, is the single quote method
faster? And which one
>will be or is already deprecated?
All are correct and won't be deprecated. IMHO it's more or
less just
personal preference. It also depends on the used editor and
its syntax
highlighting capabilities. For example I use Eclipse/PDT for
all my PHP
scripts, which can also highlight variables inside a string.
But if the
above is your preferred way, there's nothing really wrong
with it.
Just some additional thoughts:
Personally I prefer as less escaping and concatenating as
possible,
because such a mixture of single quotes, double quotes, dots
and
sometimes even escaped quote signs (for example when printing
HTML)
_really_ confuses me. I like to keep my code clean and
readable.
Something like this:
print "<img src=\"".$someVar."\" ...>\n";
not only hurts my eye, it is also quite error-prone. It's
easy to miss a
quote or a backslash and get a parse error back, especially
in editors
with limited syntax highlighting (or none at all). So I would
prefer
print "<img src='$someVar' ...>\n";
or even
printf("<img src='%s' ...>\n", $someVar);
When it comes to performance issues, of course there's a
difference
between the various methods. But for me they don't really
matter. In
practice you usually won't notice any difference between an
echo, a
print or a printf() call for example, as long as you don't
call them
a million times in a loop.
So I always just use the method that leads to the most
readable code.
In many cases, especially when a lot of variables or
expressions are
involved, (s)printf() wins. Not for performance, but for
readability.
But as said - personal preference. YMMV.
Micha

Similar Messages

  • Drop down menu for birthday, inserting into Mysql

    I have a registration form that inserts a new record into
    mysql.
    For the birthday, I have two spryselect dropdowns (month and
    day), and one spry textfield (year).
    Once the user submits the form, how can the selected values
    (month and day) be combined with the inputted year so mysql can
    accept it: YYYY-MM-DD.
    Here is my insert code. I tried concat but I don't think I
    did it right.
    if ((isset($_POST["MM_insert"])) &&
    ($_POST["MM_insert"] == "form1")) {
    $insertSQL = sprintf("INSERT INTO members (Username,
    Password, `First`, `Last`, Birthday, Address1, Address2, City,
    `State`, Zip, Phone, Email, Newsletter) VALUES (%s, %s, %s, %s, %s,
    %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['Username'], "text"),
    GetSQLValueString($_POST['Password'], "text"),
    GetSQLValueString($_POST['First_Name'], "text"),
    GetSQLValueString($_POST['Last_Name'], "text"),
    GetSQLValueString($_POST['Birthday'], $year.$month.$day),
    GetSQLValueString($_POST['Address1'], "text"),
    GetSQLValueString($_POST['Address2'], "text"),
    GetSQLValueString($_POST['City'], "text"),
    GetSQLValueString($_POST['State'], "text"),
    GetSQLValueString($_POST['Zip'], "int"),
    GetSQLValueString($_POST['Phone_Number'], "int"),
    GetSQLValueString($_POST['EMail_Address'], "text"),
    GetSQLValueString($_POST['Newsletter'], "text"));

    chris.cavage wrote:
    > Here is my insert code. I tried concat but I don't think
    I did it right.
    Assuming you have named the select elements and text field
    "month",
    "day", and "year", you need to add this somewhere near the
    top of the page:
    if (isset($_POST['month']) && isset($_POST['day'])
    isset($_POST['year'])) {
    $_POST['birthday'] =
    "{$_POST['year']}-{$_POST['month']}-{$_POST['day']}";
    } else {
    $_POST['birthday'] = 0;
    Then change this:
    > GetSQLValueString($_POST['Birthday'],
    > $year.$month.$day),
    to this:
    GetSQLValueString($_POST['Birthday'], "text"),
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS4",
    "PHP Solutions" & "PHP Object-Oriented Solutions"
    http://foundationphp.com/

  • Select Insert into staging table does not load varchar2

    I have a select insert query that loads a prebuilt table. I am running this query through Heterogenous services which points to a MySql database.
    If I run just a select query in SQL PLUS then it returns all rows just fine.
    However, when I put the select insert into a stored procedure, compile it, then run it. It does not load any VARCHAR2 datatypes but it does load DATE and NUMBER datatypes.
    I also have another table with VARCHAR2 and it loads fine.
    How can the database only load some of the items in a row and not others (VARCHAR2)
    For instance, the query will load TRANSACTION_ID, ORER_NUMBER but will not load any data into BILLFIRST_NAME, and their is data to load.
    CREATE TABLE "TRAN_STG"
    (     "TRANSACTION_ID" NUMBER(11,0),
         "ORDER_NUMBER" NUMBER(20,0),
         "BILL_FIRST_NAME" VARCHAR2(100 BYTE),
    Any suggestions would be appreciated.

    can it be that there are differences in characterset? Can it be that there are differences in datatypes? Can it be that there are differences in field length?

  • How to select value from list with multiple selections ?

    HI,
    i have a list with multiple selections where i show email address retrieved from database.
    what i want to do is to send the selected email address to the invoiceedit.jsp.
    please look at the following code which gives you the better idea.
    <td class='smalltext'><select name="email" size="3" multiple="multiple">
       <% 
       Connection conn = null;
       Statement stmt = null;
       Statement stmt_contactperson = null;
       Statement stmt_address = null;
       try{
          conn = getREConnection();
           stmt = conn.createStatement();
       ResultSet rs = null;
       rs = stmt.executeQuery("SELECT PROPERTYID, VALUE FROM PROPERTIES WHERE ENTITYID="+ g_strGroupID+" AND NAME = 'invoice_default_email'");
       int numofrows = 0;
       while(rs.next())
               %>
       <option value="<%= rs.getString("VALUE") %>" selected="selected"> <%= rs.getString("VALUE")  %> </option>
        <%
           }//end of while
          %>
         </select>
        <a href="invoiceedit.jsp?entityid=<%=g_strGroupID%>&add=1"><font color="#000000">Add</font></a>
         <a href="invoiceedit.jsp?entityid=<%=g_strGroupID%>&email_to="><font color="#000000"> Edit</font></a> </td>thanks

    Use a form button instead of a link so that you can send it as a request parameter to the server. In the server side just use HttpServletRequest#getParameterValues() to obtain all values for the given parameter name. If you really need a link rather than a button, then use Javascript to submit the form on click of the link.
    That said, your design is bad. Java code belongs in Java classes, not in JSP files. Database access logic belongs in a DAO class. Business and controlling logic belongs in a Servlet class. Only presentation logic belongs in the JSP file. Avoid scriptlets as much as possible and use JSP EL and/or JSTL instead.

  • [svn:fx-trunk] 10943: Fix to dragging from List with multiple-selection

    Revision: 10943
    Author:   [email protected]
    Date:     2009-10-08 15:46:27 -0700 (Thu, 08 Oct 2009)
    Log Message:
    Fix to dragging from List with multiple-selection
    - The fix is to postpone the selection commit until we make sure the user has not started a drag gesture.
    - Exclude the dragEnabled, dropEnabled, dragMoveEnabled properties for DropDownList
    QE notes: None
    Doc notes: None
    Bugs: None
    Reviewer: Deepa
    Tests run: checkintests, mustella List, DropDownList
    Is noteworthy for integration: No
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DropDownList.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as

  • List with multiple selection

    Hello;
    I seek a code to implement a list with multiple selection for a browser Web (HTML is imited).
    I have a list containing of the years, the user can select one or several years and I created dynamically a array : for each year a column.
    Thank you;

    Look at JList.
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JList.html
    � {�                                                                                                                                                                           

  • Need help on inserting multiple selection values into database

    Hello every body,
    we are developing one small web application in that we have requirement like department is an combobox, services in multiple selection list box, suppose when i select IT as department & some services in multiple listbox on clicking map button selected services should be map with that department .Could u plz help me how i have to do..?
    Thanks & Regards,
    Anil.

    anilmekala.reddy wrote:
    Hello every body,
    we are developing one small web application in that we have requirement like department is an combobox, services in multiple selection list box, suppose when i select IT as department & some services in multiple listbox on clicking map button selected services should be map with that department .Could u plz help me how i have to do..?
    Thanks & Regards,
    Anil.if you give more details .... do you know how to use jdbc ??? prepared statement ???
    any way if I have understood your question
    I will suppose that you have 3 tables Department ,service and Has_service
    and I supose that you have already the entry in table department and service
    Here is what I would do ...
    while(I have something to insert )
       insert into Has_service values (department,service )
    }

  • Inserting Into MYSQL Table Via Air/PHP = Not Allowed?

    I'm having trouble inserting data into my mysql database tables through my air app. All the code is pretty much exactly the same as in some examples I've seen but it simply won't do it. Is this because of some sort of security restriction because the air app is on my machine and the server with my mysql database on is elsehwhere? Or is it possible to insert data via an air app?
    Here is the example I've been following:-
    http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html

    jimmyoneshot wrote:
    Thanks for the answers boys. I've decided I'm going to change it into a flex app instead as then there won't be any problems. It simply means I'll have to add a logon system to it.
    While were on the subject do you guys happen to know of any examples anywhere of how someone can REMOVE data from an sql table via flex/php?
    What I'm looking for is basically when a user uses my app and enters info into some text inputs, if that specfic info exists within a table then that data will be removed from the table. The way this works is that they will choose an item within a tilelist which is populated by the data from this mysql table and this will insert the data of the selected item into the text inputs and then they click a remove button to remove that item. Can't find anything similar anywhere though.
    You will have to use a common identifier, eg:
    give each row in your database an ID.
    then pass that ID value on the button press to a PHP script, which does something like:
    $deleteID = $_POST["delID"];
    mysql_query("DELETE FROM exampleTable WHERE ID='$deleteID
    maybe check that a row with that ID exists first for verification, then pass back a value indicating if removal was a success or not.
    You can delete on other values, but remember they have to be unique for the database, else you'll run the risk of deleting multiple values.
    Or you could delete on a compound key, depends on the data you're storing in the grid.

  • How can I create a XMP List with multiple selection

    Hello,
    I try to build my own XMP custom panel. Herefore I need a couple of lists with the possibility for multiple selections (e.g. the choice for one language or multiple languages).
    But how is it possible to integrate a list into a panel? There is no XMPList inside the custom folder. I have experimented with the standard mx:list and an array collection for data binding into the list. But how can I write the user selection into an XMP field? Example: In the List the user choose three languages (DE, EN, FR). Is it possible to collect the choice into a string and to write the result into an XMP standard field (e.g. dc:description)?
    A further question is, if it's possible to use the "HTTPService" to bind an external xml-file with the languages and other informations into the panel or is it only possible to work with an array collection inside the code?
    Here is my code:
    <?xml version="1.0" encoding="utf-8"?>
    <fi:XMPForm
              xmlns:mx="http://www.adobe.com/2006/mxml"
              xmlns:fi="com.adobe.xmp.components.*" width="100%" height="100%"
              xmlns:Iptc4xmpCore ="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
              label="XMP-Custom Panel"
              initialize="ds.send()"
              >
         <!-- Each namespace prefix that is used within an xmpPath-attribute,
               MUST BE registered at the top of EACH panel where it is referenced -->
         <fi:XMPNamespaces>
              <fi:XMPNamespace prefix="dc" value="http://purl.org/dc/elements/1.1/"/>
         </fi:XMPNamespaces>
         <fi:XMPForm>
              <mx:HBox width="100%" height="26" verticalAlign="middle">
                   <mx:HRule width="50%"/>
                   <mx:Label text="Allgemeine Metadaten" fontSize="12" fontWeight="bold"/>
                   <fi:XMPSeparator width="50%"/>
              </mx:HBox>
              <fi:XMPFormItem
                        label="Titel"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%">
                   <fi:XMPTextInput xmpPath="dc:title" xmpType="Localized" width="100%"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Titel"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%">
                   <fi:XMPTextInput xmpPath="dc:title" xmpType="Localized" width="100%"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Druckkennzeichen"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%">
                   <fi:XMPTextInput xmpPath="dc:title" xmpType="Localized" width="100%"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Verfasser"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Erzeuger des Dokumentes" fontSize="11" width="100%">
                   <fi:XMPComboBox xmpPath="dc:creator" width="100%"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Versionsnummer"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%">
                   <fi:XMPComboBox xmpPath="dc:creator" width="100%"/>
              </fi:XMPFormItem>
              <mx:HBox width="100%" height="26" verticalAlign="middle">
                   <mx:HRule width="50%"/>
                   <mx:Label text="Enthaltene Sprachen" fontSize="12" fontWeight="bold"/>
                   <fi:XMPSeparator width="50%"/>
              </mx:HBox>
              <!-- Beginn der Auswahl-Liste für die Sprachen -->
                 <mx:Script>
            <![CDATA[
                import flash.events.MouseEvent;
                import mx.controls.Alert;
                import mx.collections.ArrayCollection;
                private const NL:String = "\r";
                // A data provider created by using ActionScript
                [Bindable]
                private var subscriptions:ArrayCollection =
                    new ArrayCollection
                            {data:0, label:"Deutsch"},
                            {data:1, label:"Englisch"},
                            {data:2, label:"Französisch"},
                            {data:3, label:"Italienisch"}
                [Bindable]
                private var market:ArrayCollection =
                    new ArrayCollection
                            {data:0, label:"(Bitte Marktversion auswählen)"},
                            {data:1, label:"Marktversion Deutsch (M_DE)"},
                            {data:2, label:"Marktversion Englisch (M_EN)"},
                            {data:3, label:"Marktversion Frankreich (M_FR)"},
                            {data:4, label:"Marktversion Italien (M_IT)"}
                [Bindable]
                private var documenttyp:ArrayCollection =
                    new ArrayCollection
                            {data:0, label:"(Bitte Dokumenttyp auswählen)"},
                                  {data:1, label:"Gebrauchsanweisung"},
                            {data:2, label:"Ersatzteilkatalog"},
                            {data:3, label:"Service-Anleitung"},
                            {data:4, label:"Etikett"}
            ]]>
        </mx:Script>
                    <fi:XMPFormItem label="Sprachauswahl" width="100%">
                    <mx:List
                        id="userSubscriptions" rowCount="4"
                        allowMultipleSelection="true" width="100%"
                        dataProvider="{subscriptions}"
                    />
                </fi:XMPFormItem>
                    <mx:Text text="* Mehrfachauswahl möglich." fontWeight="normal" fontSize="10"/>
                <!-- Ende der Liste für die Auswahl von Sprachen -->
              <fi:XMPFormItem
                        label="Marktvariante"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%">
                   <fi:XMPComboBox xmpPath="dc:creator" width="100%" dataProvider="{market}"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Dokumenttyp"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%">
                   <fi:XMPComboBox xmpPath="dc:creator" width="100%" dataProvider="{documenttyp}"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Stichworte"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Erzeuger des Dokumentes" fontSize="11" width="100%">
                   <fi:XMPTextArea/>
              </fi:XMPFormItem>
              <mx:HBox width="100%" height="26" verticalAlign="middle">
                   <mx:HRule width="50%"/>
                   <mx:Label text="Metadaten Photoshop" fontSize="12" fontWeight="bold"/>
                   <fi:XMPSeparator width="50%"/>
              </mx:HBox>
              <fi:XMPFormItem
                        label="Originalname FA"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%" id="PS1">
                   <fi:XMPTextInput xmpPath="dc:title" xmpType="Localized" width="100%"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Fotoauftragsnummer"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Dateiname" fontSize="11" width="100%" id="PS2">
                   <fi:XMPTextInput xmpPath="dc:title" xmpType="Localized" width="100%"/>
              </fi:XMPFormItem>
              <fi:XMPFormItem
                        label="Interne Anmerkungen"
                        labelTooltip="$$$/xmp/sdk/custompanels/Test/TitleToolTip=Erzeuger des Dokumentes" fontSize="11" width="100%" id="PS3">
                   <fi:XMPTextArea/>
              </fi:XMPFormItem>
              <mx:Text text="* hier steht eine kleine Erläuterung" fontWeight="normal" fontSize="10"/>
         </fi:XMPForm>
    </fi:XMPForm>
    Any suggestions?
    Thank you in advance.
    Markus

    Hi Markus,
    the FileInfo SDK does not offer a ready-made list component allowing for multi-selection.
    So you would need to implement one using the FileInfo SDK API. Your component "XMPList" would inherit from mx:list and would need to implement the XMPRead and XMPWrite events and talk to the XMP using the IXMPAccess interface within those event handlers.
    Please have a look at the Programmer's Guide, section "XMP Flex components" and at the API description available in "docs" for further guidanc.
    Hope this helps
    Kind Regards
    Jörg
    Adobe XMP

  • Unable to insert into mysql from flash burrito

    I'm having issues inserting a record to mysql, if I use the test "test operation and use these values the it works fine, but now in the android app.
    values in my test operation
        id:0,
        type:"cool",
        navn:"vegar 16"
    the getall method works fine, and shows up on the network monitor, but the button dont work at all, nothing happends in the network monito, if I debug it I can see that the button works, any suggestions on what Im doing wrong?
    code in my view:
    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:kunderservice="services.kunderservice.*"
            title="Home">
        <fx:Script>
            <![CDATA[
                import mx.events.FlexEvent;
                import valueObjects.Kunder;
                protected function list_creationCompleteHandler(event:FlexEvent):void
                    getAllKunderResult.token = kunderService.getAllKunder();
                protected function button_clickHandler(event:MouseEvent):void
                    var item:Kunder = new Kunder();
                    item.id=0
                    item.navn="vegar"
                    item.type ="test"
                    createKunderResult2.token = kunderService.createKunder(item);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <s:CallResponder id="getAllKunderResult"/>
            <kunderservice:KunderService id="kunderService"/>
            <s:CallResponder id="createKunderResult2"/>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:List id="list" x="35" y="45" width="409" height="193"
                creationComplete="list_creationCompleteHandler(event)" labelField="navn">
            <s:AsyncListView list="{getAllKunderResult.lastResult}"/>
        </s:List>
        <s:Button id="button" x="20" y="406" label="Button" click="button_clickHandler(event)"/>
        </s:View>

    I really appreciate your help. Yes indeed, debugging and seeing what is going on in general is most difficult with flash!
    Once I get this cracked I should be able to complete a lot of what I am trying to achieve.
    After inserting some echo's into my php as such:
    <?php
    $player = $_POST['player'];
    $tournament = $_POST['tournament'];
    $position = $_POST['position'];
    $prize = $_POST['prize'];
    mysql_connect("localhost", "root","poker");
    echo "onnected to database"
    mysql_select_db("poker");
    echo "database connected";
    mysql_query("INSERT INTO results(player,tournament,position,prize) VALUES
    ('$player','$tournamnet','$position','$prize')");
    echo "result added";
    ?>
    The returned info is a load of nonsense to me:
    response from server:  %3C%3Fphp%0A%24player%20=%20%24%5FPOST%5B%27player%27%5D%3B%0A%24tournament%20%3D%20%24%5 FPOST%5B%27tournament%27%5D%3B%0A%24position%20%3D%20%24%5FPOST%5B%27position%27%5D%3B%0A% 24prize%20%3D%20%24%5FPOST%5B%27prize%27%5D%3B%0A%0Amysql%5Fconnect%28%22localhost%22%2C%2 0%22root%22%2C%22poker%22%29%3B%0Aecho%20%22onnected%20to%20database%22%0Amysql%5Fselect%5 Fdb%28%22poker%22%29%3B%0Aecho%20%22database%20connected%22%3B%0Amysql%5Fquery%28%22INSERT %20INTO%20results%28player%2Ctournament%2Cposition%2Cprize%29%20VALUES%20%0A%28%27%24playe r%27%2C%27%24tournamnet%27%2C%27%24position%27%2C%27%24prize%27%29%22%29%3B%0Aecho%20%22re sult%20added%22%3B%0A%3F%3E

  • Noob help to format date to insert into mysql

    Sorry, if this question has been asked before, I did di a search but could not find an answer that I could understand.  I am pretty new to DW and my coding skills are not good so please go easy on me.
    I have a simple form to insert records to a mysql database.  I have created a form validarion behaviour to require the fields that are set as not-NULL in the database.  How do I modify the code to allow the date format to be entered in the dob field in the form as DD/MM/YYYY but inserted correctly in the database as YYYY/MM/DD?
    Finally, how would I then modify it further to default to todays date?
    Here's my code:
    <?php require_once('Connections/mypms.php'); ?>
    <?php
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO demographics (title, firstname, surname, dob, address1, address2, town, county, postcode) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['firstname'], "text"),
                           GetSQLValueString($_POST['surname'], "text"),
                           GetSQLValueString($_POST['dob'], "date"),
                           GetSQLValueString($_POST['address1'], "text"),
                           GetSQLValueString($_POST['address2'], "text"),
                           GetSQLValueString($_POST['town'], "text"),
                           GetSQLValueString($_POST['county'], "text"),
                           GetSQLValueString($_POST['postcode'], "text"));
      mysql_select_db($database_mypms, $mypms);
      $Result1 = mysql_query($insertSQL, $mypms) or die(mysql_error());
    $recordID = mysql_insert_id();
      $insertGoTo = "detail_tab.php?recordID=$recordID";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
      exit();
    $colname_insert = "1";
    if (isset($_GET['recordID'])) {
      $colname_insert = (get_magic_quotes_gpc()) ? $_GET['recordID'] : addslashes($_GET['recordID']);
    mysql_select_db($database_mypms, $mypms);
    $query_insert = sprintf("SELECT px_id, title, firstname, surname, dob, address1, address2, town, county, postcode FROM demographics WHERE px_id = %s", $colname_insert);
    $insert = mysql_query($query_insert, $mypms) or die(mysql_error());
    $row_insert = mysql_fetch_assoc($insert);
    $totalRows_insert = mysql_num_rows($insert);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>address</title>
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_validateForm() { //v4.0
      var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
      for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
        if (val) { nm=val.name; if ((val=val.value)!="") {
          if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
            if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
          } else if (test!='R') { num = parseFloat(val);
            if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
            if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
              min=test.substring(8,p); max=test.substring(p+1);
              if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
        } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
      } if (errors) alert('The following error(s) occurred:\n'+errors);
      document.MM_returnValue = (errors == '');
    //-->
    </script>
    </head>
    <body>
    <p> </p>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" onSubmit="MM_validateForm('firstname','','R','surname','','R','dob','','R');return document.MM_returnValue">
      <table align="center">
        <tr valign="baseline">
          <td nowrap align="right">Title:</td>
          <td><input type="text" name="title" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Firstname:</td>
          <td><input type="text" name="firstname" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Surname:</td>
          <td><input type="text" name="surname" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Dob:</td>
          <td><input type="text" name="dob" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Address1:</td>
          <td><input type="text" name="address1" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Address2:</td>
          <td><input type="text" name="address2" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Town:</td>
          <td><input type="text" name="town" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">County:</td>
          <td><input type="text" name="county" value="" size="32"></td>
          <td> </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Postcode:</td>
          <td><input type="text" name="postcode" value="" size="32"></td>
          <td><input name="Search" type="button" id="Search" value="Search"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right"> </td>
          <td><input type="submit" value="Insert record"></td>
          <td> </td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1">
    </form>
    <p> </p>
    </body>
    </html>
    <?php
    mysql_free_result($insert);
    ?>
    Thank you for your help :-)

    barrydocks wrote:
    thanks for the reply osgood;
    I was hoping for a more simple solution than a JQuery date picker, I have read this threat where the SQL queries is aletered:
    http://forums.adobe.com/thread/450108
    Which I tried but could not make work.
    I haven't tried DATE_FORMAT but the example implies that it would work when SELECTING the date from the database to output to a page in a more conventional FORMAT. However you want to INSERT the date using the correct format.
    barrydocks wrote:
    http://forums.adobe.com/thread/1097555
    but I don't know how to use this in my code that already has form validation?
    That thread is implying that you would need to convert the date inserted into the form field before it is inserted into the database in the correct format.......so you may as well use a datepicker.
    Problem with letting anyone insert a date manually is that a date can be written in many formats which are NOT acceptable by the database. A datepicker overcomes all of these issues. Getting the date back out of the database is a case of simply converting via php into a format which is applicable to your country or your usage OR using the method in the first thread you provided.
    Lets see if anyone else can offer a more simple solution for you.

  • JSP cannot Insert into MYSQL

    hi, i have a jsp code which can successfully return results from MySQL database. But once i change the SQL statement from a select statement to a insert statement, it does not add in a new row in the database. It has no error while compiling but it also appear nothing on the screen when being run. Has the problem got to do with the user privilages of MySQL? thanks.
    //jsp file which parameter posted from another html file. Parameter has been successfully passed.
    <%@ page import="java.sql.*"%>
    <body>
    <%
         String file = request.getParameter("file");
         String pic = request.getParameter("pic");
         ResultSet rs = null;
         ResultSet rs2 = null;
         String timestamp = "CURRENT_TIMESTAMP()";
         String q2 = "Select * from fileReqAce";
         String q1 = "INSERT INTO fileReqAce(PIC,FileName,DateReq) VALUES('"+pic+"','"+file+"',CURRENT_Timestamp())";
    try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/wendy?user=user;password=password");
    Statement state = con.createStatement();
         %><br><%
         rs = state.executeQuery(q1);
         //Statement state2 = con.createStatement();
         /**rs2 = state2.executeQuery(q2);
         %><br>
         <table border="1"><%
         while(rs2.next()){
         %>
         <tr>
         <td>Request by : <%=rs2.getString("PIC")%></td><td>File Reference : <%=rs2.getString("FileName")%></td><td>Time Requested : <%=rs2.getTimestamp("DateReq")%></td>
         </tr>
         <%
         %></table>
    <%**/
         rs.close();
    //     rs2.close();
         con.close();
         catch(Exception e)
         System.err.println("Unable to load driver");
         e.printStackTrace();
    %>
    </body>

    That all might be good and well but I think the very important thing to note here is what the first reply stated.
    If you are going to run an Insert sql statement you need to use the executeUpdate() method. You also use this function for Updates and Delete SQL statements.
    Only Select statements that return a recordset use the executeQuery() method. The executeUpdate() method returns an interger that reflects the number of rows affected by the SQL statement.
    Like when you insert 1 row the return value of the executeUpdate method will be one. You can accordingly check this returned value to see if the operation ran successfully. A return value of 0 means that now rows where inserted.
    That is my 2c worth. I hope it helped some.

  • How to insert into mysql the creation time and modification time from java?

    first how?
    Second what is better from create the date from java or do it from mysql?
    thanks in advace
    Pedro

    One way is to use the GetDate function in mysql. This will set the date as you insert data. insert into table(date) values(getdate())
    Anytime you modifiy the table just call the function again and update its fields.
    Dont know which is beter to do. In java or on the database side.

  • Dropdown list with multiple selections

    I need to create a dropdown list in a selection screen and allow the user to select more than one option. Can this be done. I know how to use VRM_SET_VALUES to create a dropdown but it restricts me to selecting only one value. The user should be able to select multiple values. Thank you.

    Hello,
    Try to use this Fm
    PARAMETERS :
    y_p_list TYPE char32  AS LISTBOX VISIBLE LENGTH 22
                                  MODIF ID rsg. .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR y_p_list.
      PERFORM y_f_dring_type_f4.
    FORM y_f_file_frmt_f4 .
      MOVE: text-212 TO y_wa_listbox1-field.
      APPEND y_wa_listbox1 TO y_i_listbox1.
      CLEAR y_wa_listbox1.
      MOVE  text-213 TO y_wa_listbox1-field.
      APPEND y_wa_listbox1 TO y_i_listbox1.
      CLEAR y_wa_listbox1.
      MOVE  text-214 TO y_wa_listbox1-field.
      APPEND y_wa_listbox1 TO y_i_listbox1.
      CLEAR y_wa_listbox1.
      MOVE  text-215 TO y_wa_listbox1-field.
      APPEND y_wa_listbox1 TO y_i_listbox1.
      CLEAR y_wa_listbox1.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'FIELD'
          dynpprog        = sy-repid
          stepl           = 1
          value           = ' '
          value_org       = 'S'
          display         = ' '
        TABLES
          value_tab       = y_i_listbox1[]
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
      ENDIF.
      REFRESH y_i_listbox1.
    ENDFORM.                    " y_f_file_frmt_f4
    Use this code you will get the List box in selection screen.

  • Applescript list with multiple selections

    Hello guys, i have h big problem...
    i was trying the multiple selections part by the command list, but if i select 2- and more it does nothing (i'm using if x is y then *linebreake* else if ...)
    so i tried another way script:
    tell application "Finder"
      --get folders of me--
              set a to get name of folders of folder "Contents:Resources:Versionen" of (path to me) --in this folder i got folders named  {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}--
              set b to choose from list a with prompt "Choose your Minecraft Version!" with multiple selections allowed
      --next step--
      count b
              set c to result
              repeat c times        --with this part i wanted to handle every selected folder as an individual to duplicate it somewere else
                        set ab to b * -1
      duplicate folder ab to folder (choose folder)
              end repeat
    end tell
    thanks for helping me

    The following script (tested under OS X 10.8.2) should do what you are asking for:
    tell application "Finder"
        set theSourceFolder to folder "Contents:Resources:Versionen" of (path to me)
        set theFolderNames to get name of folders of theSourceFolder
        set theChosenNames to choose from list theFolderNames with prompt "Choose your Minecraft Version!" with multiple selections allowed
        if result is false then return
        set theDestinationFolder to choose folder
        repeat with thisName in theChosenNames
            duplicate folder thisName of theSourceFolder to theDestinationFolder with replacing
        end repeat
    end tell
    Message was edited by: Pierre L.

Maybe you are looking for

  • My computer crashed, i have my library on an external drive, so how do i get it back into itunes?

    Okay so my dad keeps refusing to get a new computer, or a separate laptop for me. Iritatingly, it continues to crash so severely that the hardrive has been wiped clean and restored at least 4 times. Ridiculous. Luckily, I was able to save my library

  • Where is old ImageReady Layers to Files functionality?

    Back in CS2 in ImageReady (now long gone from the Adobe lineup) there was the ability to efficiently export the layers in a Photoshop doc to individual layers. It did this very very quickly and it gave you a TON of control on how the files were named

  • Compiling with ant.

    Hello all, I wonder why I´m having always this error: Error: Unable to locate specified base class 'mx.core.Application' when i compile my application via ant by using an exec task: <exec executable="${flex.mxmlc}" failonerror="true"> <arg line="${sr

  • Pages is too slow

    My pages app is too while while typing, I have to wait until the word is complete. So i restarted my mac but nothing changed, so i turned off and on my computer but pages still the same. What is wrong? What i have to do to solve this? (I have the las

  • Flash Player v.10 ignores actionscript 2.0 or 3.0 commands.

    Hi, I am using Flash CS3, and have downloaded and installed the latest version 10 flash player from Adobe site. When I create a new flash document, I select "actionscript 2.0" for the new document. Having completed the animation when I test the file