SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    uk
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    unexpected result. Help needed !

    When I post my form to a PHP script I get garbage:

    $Query
    \n"); if (mysql_query ($DBName, $Query, $Link)) { print ("The query was successfully executed
    \n"); } else { print ("The query coud not be executed
    \n"); } mysql_close ($link); ?>


    The view source is:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>HandleForm2</title>
    </head>

    <body>
    <?php
    /*this page receives and handles the data frm form.html*/
    //trim the incoming data

    $Array ["Company"] = trim ($Array["Company"]);
    $Array ["Logo"] = trim ($Array["Logo"]);
    $Array ["Strapline"] = trim ($Array["Strapline"]);
    $Array ["Activity"] = trim ($Array["Activity"]);

    $Array ["Contact"] = trim ($Array["Contact"]);
    $Array ["Phone"] = trim ($Array["Phone"]);
    $Array ["Mobile"] = trim ($Array["Mobile"]);
    $Array ["Email"] = trim ($Array["Email"]);

    $Array ["Add1"] = trim ($Array["Add1"]);
    $Array ["Add2"] = trim ($Array["Add2"]);
    $Array ["Add3"] = trim ($Array["Add3"]);
    $Array ["Add4"] = trim ($Array["Add4"]);

    $Array ["Postcode"] = trim ($Array["Postcode"]);
    $Array ["Text"] = trim ($Array["Text"]);

    //Set the variables for the database access

    $Host= "localhost";
    $User= "root";
    $Password = "123";
    $DBName = "NewDatabase";
    $TableName = "Feedback";

    $Link = mysql_connect($Host, $User, $Password);

    $Query= "INSERT into '$TableName'
    (company,logo,strapline,activity,contact,phone,mobile,email,add1,add2,add3,add4,postcode,text)
    values ('0',
    '$Array[company]',
    '$Array[Logo]',
    '$Array[Strapline]',
    '$Array[Activity]',
    '$Array[Contact]',
    '$Array[Phone]',
    '$Array[Mobile]',
    '$Array[Email]',
    '$Array[Add1]',
    '$Array[Add2]',
    '$Array[Add3]',
    '$Array[Add4]',
    '$Array[Postcode]',
    '$Array[Text]')";

    //The following line is a test for developemnt only. Then remove it.
    print ("The query is br> $Query <p>\n");

    if (mysql_query ($DBName, $Query, $Link)) {
    print ("The query was successfully executed<br>\n");
    } else {
    print ("The query coud not be executed<br>\n");
    }

    mysql_close ($link);
    ?>
    </body>
    </html>

  2. #2
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    we need to see the garbage you get, eg the error messages if any ...in saying that ..

    values ('0','$Array[company]',

    the '0' value is not matched in hte field list , i.e. you have an extra value so removing that would be a good start.

    for debugging mysql queries mysql_error(); is more than useful.

    PHP Code:
    <?
    if (mysql_query ($DBName$Query$Link)) {
    print (
    "The query was successfully executed<br>\n" );
    } else {
    echo 
    mysql_error();
    print (
    "The query coud not be executed<br>\n" );
    }
    ?>


Bookmarks

Posting Permissions

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