RE: Having trouble to use array in SELECT statement.
Yes Rolf is correct I think this is actually a perl Q... because I assume that is perl you are using so you should declare the array as: @array = qw(bla bla bla bla lba); Secondly using the array in the select will not give the desired results because it will print out something like select bla bla bla bla bla lba from ... notice the lack of "," (commas) between the names... not a good solution I am afraid. regards Barry -Original Message- From: Rolf Hopkins [mailto:[EMAIL PROTECTED]] Sent: 27 February 2001 04:42 To: David Jacobowitz; [EMAIL PROTECTED] Subject: Re: Having trouble to use array in SELECT statement. A suggestion. I don't know what language you're using but try printing $quary to the screen before it is passed to mysql. If @inc_re is an array, as you say, then in a lot of other languages, you're next line would be an illegal statement. Even the first statement looks incorrect but I don't know. Shouldn't the strings be quoted? Why do you want to create an array in the first place? Isn't it easier with just a single string? As far as I see it, your SQL statement is how I would see it and of course it would result in an error. Check the manual for the language you're using for correct syntax. - Original Message - From: "David Jacobowitz" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 27, 2001 9:41 Subject: Having trouble to use array in SELECT statement. Hello, I have constructed an array using my table field names and trying to pass that array in the select statement. @inc_re = ( Hotels, Asian_Real_Estate, Smart_Buildings, Real_Estate, Senior_Living_Homes ); $quary = "SELECT @inc_re FROM incu_real_estate LIMIT 1"; But I am getting following error. ..]$./test.pl In string, @inc_sf now must be written as \@inc_sf at ./test.pl line 15, near "SELECT @inc_sf" I have added a \ infront of the array but the quary doesn't return any thing. Any suggestions? Thanks for any help. David. _ Get your FREE download of MSN Explorer at http://explorer.msn.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 - 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 - 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: help! perl and MySQL Beginner Warning!
Hi Thomas well it may be that the install put it in another directory other than in the ones listed below I too am a bit of a beginner with perl and mysql but I found my DBI stuff in another dir so I used the following in my perl script use lib "dir/path/here/to/libs"; This tells perl to look in another dir(including the original path) for the modules... and it solved my problems, maybe not the best method but it did work, what I would like to know from ppl eventually tho is how to modify the @INC variable at a user level, IE when I log into my machine! but that I guess is for another mailing list... hope this helps you too -Original Message- From: Thomas O'Neill [mailto:[EMAIL PROTECTED]] Sent: 22 February 2001 12:17 To: [EMAIL PROTECTED] Subject: help! perl and MySQL Beginner Warning! I have built a small guestbook using perl and MySQL when i try to run my perl script i get the following error. Software error: [Thu Feb 22 14:38:01 2001] DBI.pm: Can't locate DBI.pm in @INC (@INC contains: /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005) at /home/httpd/cgi-bin/guestbook.cgi line 8. BEGIN failed--compilation aborted at /home/httpd/cgi-bin/guestbook.cgi line 8. I have installed MySQL and the two perl plugins DBI and DBD using fooperl -MCPAN -e 'install DBI' fooperl -MCPAN -e'install DBD::mysql' Does anyone know where I should go from here? (Redhat 6.2, Apache) - 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 - 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: Save image to database
Hi I asked the same Q a while ago about bin data if you look in the archives of this list it should still be there look under "binary data" as the subject To point you in the right direction tho here are some excerpts from my answers that I kept... if you look at the second excerpt there is a perl example to laod the data, but I think that there is a function called loadfile() I think and you can use this too! I just remember seeing it, but I forgot to save that message :-( Apparently it escapes all your bin zeros, ", \ etc although after lots of discussions with other ppl we decided it is better to have a reference to the files instead of storing the actual file on the DB, although ppl, do still find it useful to do it, we didnt... Hope this helps = 1. http://www.bitbybit.dk/mysqlfaq/faq.html#ch7_13_0 http://www.bitbybit.dk/mysqlfaq/faq.html#ch14_1_0 2. Hi Barry, I do not know what do you use for feeding your database, but in Perl you shoud use the DBI module, and insert the binary data through bindings. use DBI; use strict; ... my $dbh = DBI-connect("dbi:mysql:image_db", "user", "password") || die "$DBI::errstr\n";# connect to the database ... my $sth = $dbh-prepare("INSERT jpeg_table SET size_x = $size_x, size_y =$size_y, image_data = ?;") || die "$DBI::errstr\n";# prepare the insert statement, replacing the image data with a question mark $sth-bind_param(1, $image_data); # binding the binary data $sth-execute() || die "$DBI::errstr\n";# executing the insert ... $dbh-disconnect(); # disconnect Regards, Peter Szekszardi 3. -Original Message- From: Didi [mailto:[EMAIL PROTECTED]] Sent: 21 February 2001 10:35 To: [EMAIL PROTECTED] Subject: Save image to database Dear all, Can images be saved in an mysql database as a BLOB? If so, how can I write the code in sql to add an image to a mysql database record, and then subsequently view image in a browser via perl programming ? --- Thank you --- - 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: i stand corrected if this is wrong - :-
oops sorry again the DBD stuff should be install Bundle::DBD::mysqlenter ... and in the rush to attempt to help, the little kahuna makes numerous mistakes... but in the end truth and justice prevails... he hopes... -Original Message- From: Irmund Thum [mailto:[EMAIL PROTECTED]] Sent: 21 February 2001 10:32 To: Barry Radloff Subject: Re: i stand corrected if this is wrong - :- Barry Radloff wrote: oops wrong site name :-( go to www.cpan.org... Sorry -Original Message- From: Barry Radloff Sent: 21 February 2001 08:16 To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: :mySQL hi ryan DBD::... are 'drivers' for perl to a specific db, you need to go to www.cpan.com and download the DBI module for perl and the relevant driver I assume mysql as this is a mysql list... alternatively if you have net access you can use: perl -MCPAN -e shell and type install Bundle::DBIENTER (i stand corrected if this is wrong) and install Bundle::mysqlENTER (see disclaimer above) cpan install Bundle::mysql Can't install Bundle::mysql, don't have an associated bundle file. :-( at /usr/lib/perl5/5.6.0/CPAN.pm line 1806 (Mysql is correct :-) read the docs and enjoy... Barry -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] -- http://it97.dyn.dhs.org -- IrmundThum +49 179 6998564 +49 6374 992541 - 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: Finding the 'field names'
hi Jamie I' not too sure about the fields for the tables but I think a better way to implement this is to seperate the items from the options hence you have three tables instead of one,ie table 1 *product_id, (other product fields) table 2 *option_id, name, value, ...(whatever you need) table 3 *+product_id, *+option_id Explanation: Table 1 is used to hold data about the product, ie data that is relevant to the product only. table 2 is used to keep track of the various options that you require. Table 3 will be used to link the product to an option. This way you can alter your options,add or delete, without changing your tables all the time, remember to to try and keep only unique data in a table otherwise you end up duplicating things. Also maintenance becomes a pain(my opinion) regards Barry -Original Message- From: Jamie [mailto:[EMAIL PROTECTED]] Sent: 31 January 2001 02:25 To: Mysql@Lists. Mysql. Com Subject: Finding the 'field names' I was wondering what the SQL command is to find the filed names of a database once it has been created. I'm trrying to write a script that will allow 'options' table to be created where there is an ID fiield for the product then fields representing each of the avalible options eg red blue green which are going to be a boolean variable. I'm hopeing that this is the best way tyo do this as each product can have multiple options and there may even be more option fields added at a later date (which is why I need to be able to find them) My table design: ___ | Product_ID | Red | Blue | Green | Yellow | A4 | A5 | |--||-|--|---|--|--| |_12345678_|__+__|_|__+__|__+___||| |_75487345_|_|__+__|___+_|__|_+__|__+_| |_43657322_|_|_|_|__||| |_12355578_|__+__|_|__+__|__+___||| |_66635678_|_|__+__|__+__|__+___|_+__|| - 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