Re: mysql and cgi
I finally got the following few lines of code to work: $userdb=$feilds{'user'}; $rows=$dbh-do (INSERT INTO bandbook (user, ect, ect, ...) VALUES(?,?,?,?,?,?,?), undef, $userdb, 'ect', 'ect', ) || die fucked up inserting data: $DBI::errstr; print $rows row(s) added to bandbook\n; I must admit that I don't understand the purpose of the ?'s but after many hours of debugging, I'm not complaining. --- Jason Wong [EMAIL PROTECTED] wrote: On Saturday 03 November 2001 04:26, paco anubis wrote: Hello, I started learning Perl 4 weeks ago and mysql 3 days ago so I know that I am in over my head, but here goes nothing. I am trying to build a Perl CGI application (using DBI) to pass form contents from a web page directly into a MySql database. I don't know how to pass the Perl variable from the form into the database. I tried to assign the value using the following code (where $feilds{user} is the Perl variable to pass): $userdb=$dbh-($feilds{user}); $rows=$dbh-do (INSERT INTO bandbook (user, ect, ect...) VALUES ($userdb, 'ect', 'ect', ...)) || die fucked up inserting data: $DBI::errstr; print $rows row succesfully added to bandbook\n; As you may have guessed the table, bandbook is still empty because the script always dies. Can anyone point me in a better direction. Due to my unfamiliarity with either language, I am definately not ruling out a syntax error. It's good practice to assign your SQL query to a variable which you can then print out for debugging purposes. It also allows you to copy and paste that query into mysql directly and see what results it yields. I think your problem is that you haven't quoted the VALUES that you're inserting. Try: $QRY = INSERT INTO bandbook (user, ect1, ect2...) VALUES ('$userdb', '$ect1', '$ect2', ...); print($QRY); ## For debugging $rows=$dbh-do($QRY) || die Error; hth -- Jason Wong Gremlins Associates www.gremlins.com.hk - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail mysql-unsubscribe-##L=##[EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php __ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail mysql-unsubscribe-##L=##[EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
mysql and cgi
Hello, I started learning Perl 4 weeks ago and mysql 3 days ago so I know that I am in over my head, but here goes nothing. I am trying to build a Perl CGI application (using DBI) to pass form contents from a web page directly into a MySql database. I don't know how to pass the Perl variable from the form into the database. I tried to assign the value using the following code (where $feilds{user} is the Perl variable to pass): $userdb=$dbh-($feilds{user}); $rows=$dbh-do (INSERT INTO bandbook (user, ect, ect...) VALUES ($userdb, 'ect', 'ect', ...)) || die fucked up inserting data: $DBI::errstr; print $rows row succesfully added to bandbook\n; As you may have guessed the table, bandbook is still empty because the script always dies. Can anyone point me in a better direction. Due to my unfamiliarity with either language, I am definately not ruling out a syntax error. Thank You, Paco __ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: mysql and cgi
oops, I meant to type Perl for 4 weeks, I am using version Perl 5.6.0 --- Michael Ayres [EMAIL PROTECTED] wrote: Hi Paco, If I could make a suggestion... I think you'll be much happier using a newer version of perl than 4. With perl 5 and up you get to use the wonderful features of DBI (Perl's database interface module) and DBD (database drivers such as the one for Mysql). Not without saying you'll get to use hundreds of other modules as well, including ones to help you with your cgi interface. Really, consider switching to Perl 5 or later... Good Luck, Michael At 12:26 PM 11/2/2001 -0800, paco anubis wrote: Hello, I started learning Perl 4 weeks ago and mysql 3 days ago so I know that I am in over my head, but here goes nothing. I am trying to build a Perl CGI application (using DBI) to pass form contents from a web page directly into a MySql database. I don't know how to pass the Perl variable from the form into the database. I tried to assign the value using the following code (where $feilds{user} is the Perl variable to pass): $userdb=$dbh-($feilds{user}); $rows=$dbh-do (INSERT INTO bandbook (user, ect, ect...) VALUES ($userdb, 'ect', 'ect', ...)) || die fucked up inserting data: $DBI::errstr; print $rows row succesfully added to bandbook\n; As you may have guessed the table, bandbook is still empty because the script always dies. Can anyone point me in a better direction. Due to my unfamiliarity with either language, I am definately not ruling out a syntax error. Thank You, Paco __ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php __ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php