#1
  1. No Profile Picture
    tbonds
    Guest
    Devshed Newbie (0 - 499 posts)
    #create query
    $sth = $dbh->prepare ("INSERT INTO inventory VALUES($prodid,$desc,$quant,$website,$last_updt,$unit_cost,$retail_pr)");
    =============================
    I'm trying to read values from a Webpage form into a Mysql table using the above. When I try to run my program Perl tells me there's a syntax error. Other than a careless mistake on my part, am I following proper syntax for setting up an SQL statement string for Perl DBI where I want to add a row of data to an existing table? Since I don't have any examples in my books, I can't be sure where I might be going wrong.

    Below is error message I get.
    ------------------------------------
    DBD::mysql::st execute failed: You have an error in your SQL syntax near ',,,,,)' at line 1 at ./add_item.cgi line 43.
    --------------------------------------------

    Thanks,
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    71
    Rep Power
    15
    I'm not expert her but I think that this will work:

    $sth = $dbh->prepare ("INSERT INTO inventory VALUES('$prodid', '$desc', '$quant', '$website', '$last_updt', '$unit_cost', '$retail_pr')");

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    singapore
    Posts
    21
    Rep Power
    0
    have u got the DBI and DBD install in ur system?? if not, type this on ur konsole. Condition is, u must have internet connection.
    >perl -MCPAN -e'install DBI' and
    >perl _MCPAN -e'install DBD::mysql'
    say no to all manual configuration if u are not an expert and for DBD, when asked for u to choose, select 'mysql only'.and use default for all the other choices..
  6. #4
  7. No Profile Picture
    tbonds
    Guest
    Devshed Newbie (0 - 499 posts)
    Pepe, your suggestion fixed the problem! Didn't know I had to "quote" program variables in my SQL expressions. I'd love it if some of my Perl books discussed more about DBI/SQL syntax.

    Thanks again.
    tbonds


IMN logo majestic logo threadwatch logo seochat tools logo