Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 26th, 2000, 12:30 PM
tbonds
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
#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,

Reply With Quote
  #2  
Old November 26th, 2000, 02:49 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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')");


Reply With Quote
  #3  
Old November 26th, 2000, 10:02 PM
sEnG sEnG is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: singapore
Posts: 21 sEnG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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..

Reply With Quote
  #4  
Old November 27th, 2000, 12:09 PM
tbonds
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Perl DBI/MySQL Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway