Results 1 to 14 of 14
  1. #1

    Unhappy it doesnt give an error and it doesnt work!

    Im doing a form that insert the values of the formfields entered into the database.. the page works just fine with no errors at all, however, it doesnt insert anything.. and im sure all the field properties are correct.. varchar for all of them and id for id with auto increment..

    while (list($name, $value) = each($HTTP_POST_VARS)) {

    echo "$name = $value<br>\n";
    } ;
    if ($submit){

    $db=mysql_connect ("localhost", "uname", "pword") or die ('I cannot connect to the database.');
    mysql_select_db ("saydnaya_requestatour");

    $tourname = $_POST["tourname"];
    $numberofpeople = $_POST["numberofpeople"];
    $language = $_POST["language"] ;
    $transport = $_POST["transport"] ;
    $date = $_POST["date"] ;
    $budget = $_POST["budget"] ;
    $hotel = $_POST["hotel"] ;
    $nationality = $_POST["nationality"] ;
    $email = $_POST["email"] ;
    $name = $_POST["name"] ;

    $sql = "INSERT INTO 'tourrequests' (tourname, numberofpeople, language, transport, date, budget, hotel, nationality, email, name) VALUES ('$tourname', '$numberofpeople', '$language', '$transport', '$date', '$budget', '$hotel', '$nationality', '$email', '$name')";

    $result = mysql_query($sql);
    echo "Thank you for request a tour, you will be emailed with the price quotation shortly" ;

    } else {

    page comes then close the else..

    try filling it in.. it will work and you will end up in the thank you page, with what u entered.. however, the data is not inserted to the db for some reason.. this is driving me mad, anyone has any ideas?


  2. #2
    Join Date
    Dec 2001
    New Hampshire
    I'm not deep into the *sql thing yet so maybe my suggestion isn't valid but whereby your values are variable, try removing the quotes
    .. just an idea

  3. #3
    nope.. doesnt work.. thanks for ur suggestion anyway.. this bug is driving me nuts :-(

  4. #4
    Join Date
    Jan 2002
    Melbourne, AU
    I'd check for an error message, something like:

    $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());


  5. #5
    You have an error in your SQL syntax near 'than USD 500, **, TEST, TEST, TEST)' at line 1

    argh.. i cant understand whats the problem.. anyways thanks lats.. but i dunno how to debug sql errors.. anyone knows how?

  6. #6
    Join Date
    May 2002
    You've got a problem with the insert of variables.

    If the variable is a string is should be enclosed in single quotes, if it's a numeric value you don't need the quotes (but only if the field in the table is structured to only accept numeric values)

  7. #7
    do you mean in the query or in defining the vars?

    Besides, what should the fields be set to accept numeric and non numeric data?

  8. #8
    Join Date
    May 2002
    I can't answer that... it depends on how you configured your database.

  9. #9
    thanks anyways rich2k.. i guess this will never work with me.. i better try the other way.. mail() function to directly email me the ofrm results but the problem there.. i dont know how to put all the variables into one variable.. and arrays are not allowed in mail() function

  10. #10
    As Rich2k said, check your conditions on your SQL fields.

    for example:

    varchar(2) won't accept 'Jimmy Jones and the Funky Bunch'

    int(5) won't accept 'lick'

  11. #11
    Join Date
    Mar 2002
    San Jose, CA
    looks like one of your variables to be inserted has a single quote in it. Check each variable for single quotes and replace it with \' ... like so:

    $var = ereg_replace("'","\'",$var);
    reliable linux hosting with all the trimmings

  12. #12


  13. #13

    check your...

    magic quotes settings in the php.ini

    also your register globals settings

  14. #14
    Cannot query the database.
    Column count doesn't match value count at row 1

    Latest error.. i removed most fields and still got the error so i put at the end of the query $lastvariable, ')" see that comma and single quote? thats what removed the errrors lol, now i have that error.. and ive no idae what it means.. i dont have much experience in SQL

Posting Permissions

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