SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot kevinritt's Avatar
    Join Date
    Nov 2002
    Location
    Lynn, Massachusetts-United States
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Form input into MySql database

    Hello everyone,
    I have been trying to get a form to send data to a database. The page the form is on is called "process.php" that info is sent to "form2mail.php" page. The script below is on that page. I don't get an error message but the data is not in the database when I check to see if it was submited.I am using PHPMyAdmin to check the database (if that helps) Please help


    $dbh=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("db_name");

    $sql = 'INSERT INTO `0rders` (`firstname`, `lastname`, `address1`, `city`, `state`, `zipcode`, `phonenumber`, `email`, `label38`, `label58`, `labelone`, `textline1`, `textline2`, `textline3`, `textline4`, `bgcolor`, `textcolor`, `motif`) VALUES (''$firstname'', ''$lastname'', ''$address1'', ''$city'', ''$state'', ''$zipcode'', ''$phonenumber'', ''$email'', ''$label38'', ''$label58'', ''$labelone'', ''$textline1'', ''$textline2'', ''$textline3'', ''$textline4'', ''$bgcolor'', ''$textcolor'', ''$motif'')';

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont do much in PHP anymore but it sounds like you may have an error coming back from the db so the datas not going in.....

    In java we are able to "catch " the exception and print out the error message from the db .......... you folks got anything like that in PHP? Its not your connection beacuse that would throw the error you have coded in your die so the error is happening on the insert....... I did find this on the PHP site ...might help

    http://us4.php.net/manual/en/function.mysql-error.php

  3. #3
    SitePoint Wizard Lats's Avatar
    Join Date
    Jun 2003
    Location
    Melbourne, AU
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless you missed posting something else of your script, you're not actually executing any sql statements.

    Try adding this to the end...
    PHP Code:
    $result mysql_query($sql) or die(mysql_error()); 
    Lats...


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
  •