|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
#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
|
|||
|
|||
|
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')"); |
|
#3
|
|||
|
|||
|
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.. |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Perl DBI/MySQL Problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|