PHP/MySQL Insert Record

I've got a multi page form that carries values across
multiple pages with the use of Hidden Fields and then on last page
inserts the record into a MySQL database (for this I used the built
in Insert Record function of dreamweaver). My problem is that it
works well when using Internet Explorer, values are carried forward
and everything is inserted successfully to the database.
But, when using Mozilla Firefox it looks as if it works, I
get the confirmation at the end, but the record is not being
inserted to the database. I've worked through this step by step and
the values are being carried across in the hidden fields but it
just will not insert anything to the database.
Has anyone got any ideas??
Thank you in advance.

Cade06 wrote:
> Thanks alot for your reply, but I am completely new to
MySQL, and I am not
> quite sure how the syntax works. When you say " WHERE
landlord_username =
> 'whatever' "I'm not sure what needs to go in the
'whatever' portion of the
> code. Do I need to insert static text here or something
else? I am totally out
> of my element here, sorry :-/
It's probably not so much MySQL syntax that's the problem for
you, but a
lack of understanding how to work with Dreamweaver
recordsets, server
behaviors, and sessions. Building database-driven sites with
Dreamweaver
isn't difficult, but there are a lot of things involved.
The Log In User server behavior automatically creates a
session variable
called $_SESSION['MM_Username']. You can use this as a
parameter to pass
to the SQL query in the Advanced Recordset dialog box. In the
SQL area
you would type (I'm guessing the name of your table and the
username
column):
SELECT landlord_id FROM landlords
WHERE landlord_username = 'col1'
Then click the plus button above the Variables area, and
create a
Parameter with the following values:
Name: col1
Default value: 1
Runtime value: $_SESSION['MM_Username']
You can then extract the result of the recordset, and assign
it to a
session variable like this:
$_SESSION['landlord_id'] = $row_recordsetName['landlord_id'];
> Also, I understand that I need to do this on the login
page, but do I need to
> define the recordset again on the add_site page as well?
I guess I'm still not
> quite clear on how I specify the session variable as the
value that needs to be
> entered in the sites table as the landlord_ID.
As long as the session is still valid (which it would be if
you use
Restrict Access to Page), you will always have access to that
landlord's
id through $_SESSION['landlord_id'].
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/

Similar Messages

  • CS6 Dreamweaver using PHP & MySQL - Delete Record Server Behavior?

    When I try to insert the Delete Record server behavior. I get an error message about a DeleteRecord.js file, which seems to be missing or defective.  I cannot use the server behavior.  I have a file that I developed using CS5, and it does indeed delete the record, but does not proceed to the destination I want.  I cannot change that except in the server behavior, so I'm stuck.  I have noticed that server behaviors seem to disappear without apparent cause, as it seems to have in this case.  I will appreciate any suggestions!  Is there any way to embed a call to a target page manually?  All is working WITHOUT the server behavior appearing, but I want to go to a confirmation display page that shows the record is indeed deleted, and we just return to the (now blank) delete confirmation page.  That'll drive a user bonkers!
    Thanks!
    Delete Record in CS6 Dreamweaver using PHP & MySQL?

    Well, your error message is self-explanatory.
    DW stores ServerBehaviors in 'Configuration' folder in installation directory. If one of the behavior JS files is missing/ corrupt, you'll see the error message you just did.
    I've uploaded a functional, proper version of DeleteRecord.js onto my site for you to download. Here's the link:
    http://www.sudarshan.me/adobeforum/dw/app/behavior-js/DeleteRecord.zip
    Download this file, extract it and put DeleteRecord.js file in your installation directory as follows. If prompted, 'replace' your local copy:
    Mac: Applications > Adobe Dreamweaver CS6 > Configuration > ServerBehaviors > PHP_MySQL
    Windows: C:\Users\Your User Name\AppData\Roaming\Adobe\Dreamweaver CS6\[language]\Configuration\ServerBehaviors\PHP_MySQL
    It should work as expected.
    If that still doesn't solve the problem, reset your DW preferences and cache and try doing it. Follow the instructions here to reset cache: http://forums.adobe.com/thread/494811
    Let us know how it goes.
    -ST

  • PHP/MYSQL Insert code

    I am new to php/MYSQL but I am trying to learn. I built an
    insert page using DW8. I was looking back over the code trying to
    figure it out. Is it just me or does dreamweaver an a bunch of junk
    to there code to do a simple insert from 4 form fields.
    Can anyone explain what DW is doing since I am now dumber for
    having looked at it.
    <?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 reviews (review_date,
    review_name, review_address1, review_city, review_state) VALUES
    (%s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['date'], "date"),
    GetSQLValueString($_POST['textfield'], "text"),
    GetSQLValueString($_POST['textfield2'], "text"),
    GetSQLValueString($_POST['textfield3'], "text"),
    GetSQLValueString($_POST['textfield4'], "text"));
    mysql_select_db($database_siteData, $siteData);
    $Result1 = mysql_query($insertSQL, $siteData) or
    die(mysql_error());
    $insertGoTo = "
    http://www.yahoo.com/";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    header(sprintf("Location: %s", $insertGoTo));
    mysql_select_db($database_siteData, $siteData);
    $query_Recordset1 = "SELECT * FROM reviews";
    $Recordset1 = mysql_query($query_Recordset1, $siteData) or
    die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>

    newhorizonhosting.com wrote:
    > I am new to php/MYSQL but I am trying to learn. I built
    an insert page using
    > DW8. I was looking back over the code trying to figure
    it out. Is it just me or
    > does dreamweaver an a bunch of junk to there code to do
    a simple insert from 4
    > form fields.
    No, it's not a bunch of junk. It's filtering the input to
    make sure that
    things are inserted correctly into your database.
    > Can anyone explain what DW is doing since I am now
    dumber for having looked at
    > it.
    This function filters the form content to prepare it for
    insertion in
    the database.
    > function GetSQLValueString($theValue, $theType,
    $theDefinedValue = "",
    > $theNotDefinedValue = "")
    This sets the action value of the form tag, including any
    query string.
    > $editFormAction = $_SERVER['PHP_SELF'];
    > if (isset($_SERVER['QUERY_STRING'])) {
    > $editFormAction .= "?" .
    htmlentities($_SERVER['QUERY_STRING']);
    > }
    This builds the SQL query and inserts the form content into
    the database.
    > if ((isset($_POST["MM_insert"])) &&
    ($_POST["MM_insert"] == "form1")) {
    > $insertSQL = sprintf("INSERT INTO reviews (review_date,
    review_name,
    > review_address1, review_city, review_state) VALUES (%s,
    %s, %s, %s, %s)",
    > GetSQLValueString($_POST['date'], "date"),
    > GetSQLValueString($_POST['textfield'], "text"),
    > GetSQLValueString($_POST['textfield2'], "text"),
    > GetSQLValueString($_POST['textfield3'], "text"),
    > GetSQLValueString($_POST['textfield4'], "text"));
    >
    > mysql_select_db($database_siteData, $siteData);
    > $Result1 = mysql_query($insertSQL, $siteData) or
    die(mysql_error());
    This redirects the page after the database query has
    finished.
    > $insertGoTo = "
    http://www.yahoo.com/";
    > if (isset($_SERVER['QUERY_STRING'])) {
    > $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" :
    > $insertGoTo .= $_SERVER['QUERY_STRING'];
    > }
    > header(sprintf("Location: %s", $insertGoTo));
    > }
    This is unrelated to the insert. It's a recordset that
    retrieves
    everything from the reviews table of your database.
    > mysql_select_db($database_siteData, $siteData);
    > $query_Recordset1 = "SELECT * FROM reviews";
    > $Recordset1 = mysql_query($query_Recordset1, $siteData)
    or die(mysql_error());
    > $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    > $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • MySQL Insert Record

    I have a database for an operational application & I am trying to build some simple insert pages to insert records into the database.
    I have constructed the insert forms, yet when I try to inserta  record, the primary key is not automatically applying to the record, as is an auto-number that should apply to another field? yet the data is populatin within the table? I am assuming that the database would apply this automatically as it does in the application??
    what am i missing?
    Thanks
    Pete

    Hi
    Thanks for the response.
    I have edited the insert statement to take these fields out, however when I insert a record it does go into the database, but again the primary key & the autonumber do not increment?
    If i try to enter another record i get
    Duplicate entry '' for key 'PRIMARY'
    Thanks
    Pete

  • PHP/mySQL Insert/Update Problems

    I hope someone can help because I can't find anything online
    that is helping me with this problem. I can't get the Dreamweaver
    controls to work when coding a PHP insert or update record page. It
    looks like it creates the code correctly but when I put them out on
    my webserver and then fill out the form and click submit the page
    submits and tries to use a URL string of (null)/admin/index.php
    where index.php is the form page not the page I told it to redirect
    to. I don't know why the (null) value keeps getting inserted into
    the string either. The browser obviously can't find this URL so
    gives a page cannot be displayed screen and nothing get's inserted
    or updated in the mySQL database.
    Any help would be greatly appreciated. This problem is
    driving me crazy because I want to save time not having to hand
    code things. Below is a User Authentication page using the
    Dreamweaver controls that does the same thing when I try to
    login.

    tobyd wrote:
    > the page submits and tries to use a URL string of
    (null)/admin/index.php
    > where index.php is the form page not the page I told it
    to redirect to. I don't
    > know why the (null) value keeps getting inserted into
    the string either.
    The following two lines set the URL for login success and
    failure.
    > $MM_redirectLoginSuccess = "../admin_index.php";
    > $MM_redirectLoginFailed = "../admin/index.php";
    As you can see, they are relative paths, suggesting that the
    login form
    is in a different subfolder, but at the same level as
    admin_index.php
    and the admin folder. The (null) almost certainly comes from
    the fact
    that your login page is in the site root. If you're typing in
    the
    redirect filenames manually, use the Browse button instead.
    Dreamweaver
    should set the correct path for you.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • PHP-MySQL "INSERT INTO" query not working

    Hi,
    The code below fails to update a MySQL table I have made called "tampa."  I'm not sure why.  The field "id" is an index field, auto-increment, and primary-type.  The field "site" is also an index field, but just unique-type.  Does the fact that these two fields are index fields have anything to do with why the code below won't update the table?
    Thanks in advance,
    John
    <form action="process.php" method="post">
    Add a blog to this category: <input name="site" type="text" size="50">
    <input type="submit" value="Submit">
    </form>
    PHP code in a file called "process.php":
    <?
    $site=$_POST['site'];
    mysql_connect("mysqlv3", "username", "password") or die(mysql_error());
    mysql_select_db("sand2") or die(mysql_error());
    mysql_query("INSERT INTO `tampa` ('id', 'site', 'value') VALUES (NULL, '$site',1)");
    $result = mysql_query("INSERT INTO `tampa` ('id', 'site', 'value') VALUES (NULL, '$site',1)");
    ?>

    The reason it fails is because you have surrounded the column names with quotes. You are also running the insert query twice. And yet another problem: you are inserting a form value into the database without filtering it.
    <?php
    mysql_connect("mysqlv3", "username", "password") or die(mysql_error());
    mysql_select_db("sand2") or die(mysql_error());
    // strip slashes if magic quotes are enabled
    $site = get_magic_quotes_gpc() ? stripslashes($_POST['site'] : $_POST['site'];
    // make form value safe to insert in DB
    $site = mysql_real_escape_string($site);
    mysql_query("INSERT INTO `tampa` (id, site, value) VALUES (NULL, '$site',1)");
    ?>

  • PHP/MySQL search record

    Hi,
    I have a form where a user will enter their desired user name
    and their
    e-mail address. Once I see that both fields are filled in, I
    need to check
    to see if the username and/or e-mail address they entered are
    already in the
    database.
    The table is called "login_table" and the field for the
    username is "usr"
    and the field for e-mail is "email" - again, I need to check
    to see that
    these are not duplicated before I enter the data into the
    table.
    I'm a little unsure (actually, I don't know how), to do this.
    If someone
    could provide any code that would achieve this, that would be
    greatly
    appreciated.
    Thanks (if you need more info, let me know).
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Blog:
    http://avenuedesigners.com/blog/
    Web dev articles, photography, and more:
    http://sourtea.com
    =============================================
    Proud GAWDS member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================

    Well, I got around it. It's probably not the best way, but
    essentially I did
    a str_replace to get rid of all the additional data in the
    mysql_error()
    except for the username/email that is duplicated, and just
    made a general
    error message regarding which one was already in the
    database.
    Shane H
    [email protected]
    http://www.avenuedesigners.com
    =============================================
    Blog:
    http://avenuedesigners.com/blog/
    Web dev articles, photography, and more:
    http://sourtea.com
    =============================================
    Proud GAWDS member
    http://www.gawds.org/showmember.php?memberid=1495
    Delivering accessible websites to all ...
    =============================================
    "Shane H" <[email protected]> wrote in
    message
    news:[email protected]...
    > Hi Joe,
    >
    > Yeah that does work. I set UNIQUE for both the "usr" and
    the "email"
    > field. I do have one question now. Is there anyway for
    me to tell which
    > one is giving the error, so I can tailor a custom error
    message?
    >
    > If I let MySQL give me the error, like -
    >
    > mysql_error();
    >
    > It gives me -
    >
    > "Duplicate entry for blah blah blah"
    >
    > I'd like to be able to customize my error message, and I
    know how to do
    > that if I could only determine how to tell which one is
    throwing the
    > error...
    >
    > --
    > Shane H
    > [email protected]
    >
    http://www.avenuedesigners.com
    >
    > =============================================
    > Blog:
    >
    http://avenuedesigners.com/blog/
    >
    > Web dev articles, photography, and more:
    >
    http://sourtea.com
    > =============================================
    > Proud GAWDS member
    >
    http://www.gawds.org/showmember.php?memberid=1495
    >
    > Delivering accessible websites to all ...
    > =============================================
    >
    >
    > "Joe Makowiec" <[email protected]> wrote in
    message
    >
    news:[email protected]...
    >> On 05 May 2007 in macromedia.dreamweaver, Shane H
    wrote:
    >>
    >>> I have a form where a user will enter their
    desired user name and
    >>> their e-mail address. Once I see that both
    fields are filled in, I
    >>> need to check to see if the username and/or
    e-mail address they
    >>> entered are already in the database.
    >>>
    >>> The table is called "login_table" and the field
    for the username is
    >>> "usr" and the field for e-mail is "email" -
    again, I need to check
    >>> to see that these are not duplicated before I
    enter the data into
    >>> the table.
    >>>
    >>> I'm a little unsure (actually, I don't know
    how), to do this. If
    >>> someone could provide any code that would
    achieve this, that would
    >>> be greatly appreciated.
    >>
    >> Most (R)DBMS[1] systems allow for requiring that all
    values in a field
    >> be unique; for a primary key, it's required. Look
    through your DBMS's
    >> help files or reference for how to make a field a
    primary key, and how
    >> to set up a UNIQUE index. For MySQL:
    >>
    >>
    http://dev.mysql.com/doc/refman/5.0/en/constraint-primary-key.html
    >>
    >> [1] (Relational) DataBase Management System
    >> --
    >> Joe Makowiec
    >>
    http://makowiec.net/
    >> Email:
    http://makowiec.net/contact.php
    >
    >

  • Php/mysql all caps

    I have a php mysql insert record application built in
    dreamweaver. Is there a way to force or convert all inputted text
    to all caps? I tried a style sheet text transform, but that doesn't
    make the actual entry into the database all caps. Thanks.

    Admittedly though, that's pretty easy too.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Gary White" <[email protected]> wrote in message
    news:[email protected]..
    > On Tue, 13 Jan 2009 23:09:15 +0000, David Powers
    <[email protected]>
    > wrote:
    >
    >>Why? That means converting the data every time it's
    displayed. If the
    >>data is always required as uppercase, it makes more
    sense to convert it
    >>once at the time of storage.
    >
    > For the most part, I agree. However, there is the
    possibility down the
    > road, that they might want to use the data for something
    other than the
    > current ticker. In that case, it might display better in
    mixed case. It's
    > a lot easier to convert to all upper case for the
    ticker, than to try to
    > convert all upper case to mixed case.
    >
    > Gary

  • PHP/MySQL-Update/Insert Record JavaScript Won't Work!!!

    Hi. I'm consistently running into the following error when I use the update or insert record script in CS4. I've tried deleting the FileCache file. I've tried quitting and relaunching, etc. Anyone else seeing this happen? Solutions anyone? Thanks in advance...
    I'm beginning to think it has something to do with the database, and not the script. Does anything in the screenshot below look wrong or problematic?
    Okay, I found the problem. Shouldn't be a problem, but it is...
    The Field name "length" changed to "height" eliminated the problem. So, you can't use the word "length" in a field? Sounds weird to me.

    airsoftie wrote:
    Okay, I found the problem. Shouldn't be a problem, but it is...
    The Field name "length" changed to "height" eliminated the problem. So, you can't use the word "length" in a field? Sounds weird to me.
    There are lots of words you can't use for column names in MySQL, but "length" isn't one of them. See http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html.
    The problem arises because Dreamweaver uses JavaScript behind the scenes to populate dialog boxes and build server behaviors. In JavaScript, "length" is the property of an array. I suspect the problem is that using "length" as a column name has given the relevant JavaScript used by Dreamweaver indigestion.

  • PHP URL Variable from Insert Record Issue

    I have a very simplistic forum style website I have put together. Everything is functionally properly except for one aspect. The basic structure is a page that lists the existing threads (ie: ThreadA, ThreadB, and ThreadC). I have the name of these threads stored in a MySQL database table that is used to generate a repeating dynamic table to grow as the number of threads increases. If the user clicks on one of these links they are taken to a page that displays all of the comments pertaining to that thread. All of the comments are stored in another MySQL database table. I perform a query on this comments page to filter the information in the comments database by the thread name which is passed over from the first page via a URL variable. The link attached to the name of the thread in the repeating table that generates the URL variable is "comments.php?thread=<?php echo $row_threads['threadName']; ?>" This works perfectly, If the user clicks on ThreadB they are taken to the comments page where only the comments pertaining to ThreadB have been filtered and displayed. After the user inserts a comment form ThreadB the comments page reloads displaying the newly created comment.
    Also, on the first page, the user has the option to create a new thread; call it ThreadD. The name of this new thread has to be inserted into two tables; one in the master threads table and one in the comments page any time someone adds a comment. (I'm sure there is a better way to structure this, but this was all I could figure out and for my purposes at hand it is sufficient). When the user is taken to this new comment page I have a query set up to pull the last entry in the threads table from the logged in user, ie the newly created thread topic. I have dragged this query to the page to make sure it is pulling the correct thread heading, and it works just fine. What I'm wanting to have happen is after the user enters the first comment I'm wanting them to be redirected to the main comments page with their new comment listed; giving the illusion that the new comment and existing comments page are the same. I'm trying to pass the newly created thread name, ThreadD, in the URL to the main comments page just like I do if they select it from the existing threads page. Under the insert record wizard I click the 'browse' button to select the comments.php page. I then select 'parameters' to add the thread name query as the URL parameter. The generated code is "comments.php?thread=" . $row_threadName['threadName'] . "". The user does go to the main comments page but the URL variable is not coming with it. What I'm left with in the address bar is ..."/comments.php?thread=&" , but it should be ..."comments.php?thread=ThreadD". I tried copying and pasting the URL link from the existing threads page since that works perfectly, and when I do that the main comments page shows up blank after being redirected from the new comments page. If I hard code this, for testing purposes, into the redirect after insertion section (ie: "comments.php?thread=ThreadD") everything works perfectly and the URL in the address bar of the main comments page is "...comments.php?thread=ThreadD&" I noticed the extra "&", but didn't give it much thought since the site is giving me the behavior I'm looking for. My question is, how do I get this new comment page to pass the variable of the newly created thread name to the main comments page to behave like it does when the thread is selected from the list of existing threads? I know it has to do with how the URL variable is either being generated or built from my query, or how I have it listed in the redirect section of the insert wizard, but I can't figure out where I am going wrong. Please let me know if there are any questions or if I need to clarify any aspect. Any and all help is always appreciated. Thank you.

    Ok, so just to summarize so I am understanding this correctly.  You have an ordering page for tires/wheels.  A customer places an order for tires/wheels and the data is submitted successfully and this includes a symbol for measurement (in.).  But on another summary page the symbol is returning a blank value.
    If this is correct we need to see:
    - First, the code that is inserting the symbol to the database table in question
    - Second, the query and code where you are printing the data to the screen.

  • [php+mysql] how to pass data from one insert form to another?

    Hi all,
    I have an insert form (in a mysql db) on the page. Is there a way to
    view the inserted data after inserting so stat the user can print it
    out?
    TIA
    tony

    >Hi Tony,
    >let´s assume the table´s Primary Key column is named "id" -- just add this value (available as "Dynamic Data") to the "Redirect after Insert" URL in the following way:
    >print.php?id={id}
    >...and on that page add a recordset which queries the table like that:
    >"SELECT * FROM tablename WHERE id" equals the URL parameter "id"
    >That should be all there is to do.
    >Cheers,
    >Günter Schenk
    >Adobe Community Expert, Dreamweaver
    Hi Günter,
    Thanks, it works.
    I added a bit of code to set a session variable using this Parameter
    URL, so that I can manage the record ID along the whole user session.
    So, I ask you a little question: when it is best to delete or destroy
    session variables? after displaying the inserted records or just befor
    inserting the first one?
    Here is my little test workflow:
    1- destroy variable sessions (I think I will unset session variables
    one by one instead, to eliminate the risk to delete other sesssion
    variable (UserID...)
    2- insert the first record (redirect to the next page using the record
    ID1)
    3- set a session variable (S1) using the ID1 coming from previous page
    ($_GET)
    4- insert the second record (redirect to the next page using the
    record ID2)
    5- set a session variable (S2) using the ID2 coming from previous
    page ($_GET)
    6- insert the third record (redirect to the next page using the
    record ID3)
    7- set a session variable (S3) using the ID3 coming from previous page
    ($_GET)
    8- create a recordsets to filter the db by S1, S2 and S3.
    9- display the report
    it seems to work.
    do you think there is something to refine?
    Thanks again for your kindness.
    tony

  • Problem to insert id into the foreign key  php/mysql

    Hello all,
    I'm having rouble to understand the process and there is no tutorial about my problem anywhere
    I have two table:
    Table 1 (member) with id, name, phone etc
    Table2 (post) add_id, title, description, price, member_id
    I got a form to post the add and I need to insert the id of table 1 into my table 2 member_id zone
    Fisrt I did the recorset to get user id
    $colname_rsMember = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsMember = $_SESSION['MM_Username'];
    mysql_select_db($database_connect, $connect);
    $query_rsMember = sprintf("SELECT * FROM member WHERE username='".$_SESSION['MM_Username']."'")or die(mysql_error());
    $rsMember = mysql_query($query_rsMember, $connect) or die(mysql_error());
    $row_rsMember = mysql_fetch_assoc($rsMember);
    $totalRows_rsMember = mysql_num_rows($rsMember);
    This part is working and I'm able to retreive info via echo just for testing
    After this code I have my insert code
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO add (title, `description`, price, member_id) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['description'], "text"),
                           GetSQLValueString($_POST['price'], "text"),
                           GetSQLValueString($_POST['member_id'], "int"));
      mysql_select_db($database_connect, $connect);
      $Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());
      $insertGoTo = "ok.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    Do I need to include hidden field in y form?
    I'm having the same error message. Col member_id can't not be null
    Any idea what I'm doing wrong?
    Thank You!

    When someone logs in, Dreamweaver creates a session variable called $_SESSION['MM_Username']. Use that session variable to create a recordset to get the user's ID, which can then be entered into the foreign key field of the child table.
    Dreamweaver automatically puts the code for recordsets immediately above the DOCTYPE declaration, so you will need to move it above the code for the Insert Record server behavior. So, it needs to be in this order:
    Recordset to get user ID
    Insert Record for child table

  • PHP Form Validation and Insert Records

    Hi There,
    I've been scratching my head for 2 days and couldn't find a solution.
    Here is my problem:
    Go to http://ecopethandbags.com/contactTest.php and click the "Send Comments" button.
    You will see that the validation works.
    Now, go to http://ecopethandbags.com/contactTestInsert.php, this time, I've inserted the "Insert Record" server behavior.
    Click the "Send Comments" button again.
    You will see the ugly message like "Column 'firstname' cannot be null" in a plain white page.
    My question is:
    How can I insert the PHP form records in my database and take advantage of the form validation nicely like in http://ecopethandbags.com/contactTest.php
    I am attaching the files.
    Thank you for you help!

    boloco wrote:
    My question is:
    How can I insert the PHP form records in my database and take advantage of the form validation nicely like in http://ecopethandbags.com/contactTest.php
    Use simple PHP logic to merge the scripts together.
    Dreamweaver automatically puts the Insert Record server behavior code at the top of the script. You need to adapt it so that the validation is done first. If the validation succeeds, use the Insert Record server behavior. If not, redisplay the form.
    if (array_key_exists('send', $_POST)) {
      // validate the form input
      if (!$suspect && empty($missing)) {
      // send the mail
        if ($mailSent) {
        unset($missing);
        // insert the Insert Record server behavior code here

  • Inserting special character like apostrophes with PHP/Mysql

    Hi friends,
    I have a problem with php/mysql. I have created a form inton a php page with dreamweaver and when i try to fill the form with a string containing apostrophe ( ' ), i have a error. It seems that the insertion is not possible. Could you have any idea for that. I give you the php dreamweaver code and thank you for your help.
    <?php require_once('Connections/Mainconnect.php'); ?>
    <?php require_once('Zend/Date.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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":
    if ($theValue=="")
        $theValue="NULL";
    else
        $zendDate=new Zend_Date($theValue,"dd/MM/yyyy");
        $theValue="'".$zendDate->toString("yyyy-MM-dd")."'";
          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_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE pers_soc_reg SET field1=%s, field2=%s,
                           GetSQLValueString($_POST['field1'], "text"),
                           GetSQLValueString($_POST['field2'], "double"));

    "Normally, you canot use mysql_real_escape_string without connection to database"
    That is not true at all. Try running the following script.
    <?php
    if ($_POST['submit']){
    $x1=$_POST['test1'];
    foreach ($_POST as $key => $value) {
    if (!is_array($value)){
    $_POST[$key] = mysql_real_escape_string($value);
    extract($_POST);
    echo "The text after 'becomes' should be escaped (\')<br/>";
    echo "$x1 becomes $test1<br/>";
    ?>
    <hr/>
      <form action="#" method="post" />
    Enter some text, including an apostrophe: <input name="test1" type="text"><br/>
        <p><input name="submit" value="submit" type="submit"/>
      </form>

  • Insert record works for me, but not my client...

    This is odd - I basically have an ADDT insert record page to add a database record, which as far as I know worked just as it should.
    But my client is saying it doesn't work on her machine - apparently when she hits 'add record' instead of going to the page confirming the record has been added, its just reloading a blank form on the add record page.
    I've just double checked on my machine, and it definitely works for me.
    She's definitely using the correct the URL.
    Its just using mySQL / PHP / phpMyAdmin
    Is there any reason at all that this should be the case, or any ideas what is causing it and what a solution might be?
    Thanks.

    Well, apparently its working for her now in Firefox, so looks like it may have something to do with IE8. I noticed on her screenshot there was something called Internet | Protected Mode : On - so maybe that's being over zealous in some way.

Maybe you are looking for