Help with PHP to MySQL db connection
Hola, MySQL wizards. I'm using LAMP on Fedora Core 2. Some kind soul produced a tutorial on the net and the first script, , I am trying to use yields an error in the browser of: < Couldn't connect to MySQL > Here is the script. --- Birthdays Create Database $dbhost = 'localhost'; $link = mysql_connect($dbhost); if (! $link) die("Couldn't connect to MySQL"); //create database mysql_create_db("mydatabase")or die("Create Error: ".mysql_error()); mysql_close($link); ?> --- I can access all of my databases and tables with phpMyAdmin just fine, and I can access them at the command line. Of course I didn't know which user I was when was attempting to execute this php script through the browser, so I check my mysqld.log file and it claims I should be '[EMAIL PROTECTED]', so I setup this user in the mysql database. I tried adding $dbuser = 'nobody'; $dbpass = ''; to the script but to no avail even though I can access through the command prompt with with a password. When I do a the results show a --port=3306 as well as 10 connection PID's. My hello.php script works fine, as do other php scripts. When I list however, the number that gets displayed in the column after and before is 999269. I was expecting it to be 3306? How do I troubleshoot this error message? My mysqld.log looks "normal" other than a "Warning: Asked for 196608 thread stack, but got 126976>. The mysql.sock line shows . Any ideas on what to check next? I'd at a loss. TIA Andrew L. in the Heartland (not the "Hinterlands") -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Adding hypertext data element into record ...
Thank you for your replies, Mos (and Sol): So, is there there a way to store the following in a data record? http://mydomain.com/photos/acoolpic.jpg";>My Cool Photo <>Mos Wrote: RE:>>The code only becomes clickable when viewed from a browser so you need to retrieve the html string from the database and write it to an html page. AND, 1) Use whatever language you like, PHP, Perl, running on a webserver so anyone can access it over the internet or intranet 2) Or if you only need to use it locally from your machine (and not share it without anyone else) then write an .exe program that either produces an html file that has that hyperlink in it and then pull up the browser to display the file, or build a browser into your .exe file and stream the html code to that. --- RE: 1) Is there no field type/data element type/column type that will allow a string to be treated as a hypertext link directly from MySQL? Seems like there are so many other field types that the MySQL folks might have created one that can generate a hypertext link on the fly by now. It can be done within a wordprocessing document, and in an HTML document, so why not in a database? 2) I try never to use .exe programs as this implies the need to use Windows and I try to stay 100% open systems, if at all possible. So, are you saying that if I am using phyMyAdmin and displaying records to the screen, and if one of the fields contains data like "http://mydomain.com/photos/mycoolpic.jpg"; that there is no way to make this "clickable" as a hypertext link? If so, then I know that I have to write a php enabled (or perl enabled) page to accomplish this. I've used Perl in the past but will try this with PHP. I was simply trying to ascertain the state-of-the-art with MySQL... TIA for any definitive answers on this question. Andrew L. A Member of the GNU Generation
Adding hypertext data element into record ...
I've looked all over the mysql.org website, for data element/column types, and find no reference to storing data as a link to an html document or blob. I am thinking this can be done but need help with syntax. So, is there there a way to store the following in a data record? http://mydomain.com/photos/acoolpic.jpg";>My Cool Photo I can store the data, but obviously, since the display of records following a query simply displays the text, which is not hypertext enabled, there is no means to click on the data and have anything happen. IOW, is there a way to hypertext enable data in a mysql data record? TIA, Andrew L. A member of the gnu generation -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Newbie--Easy data loading question
Dear Jake and MySQL listers, RE:>> I had to change permissions on user1 to 777 in order for it to work. If I'm logged in as that user, why would I have to do that??? I can't say for certian, though I would imagine that the mysqld actually does the processing on this type of a table load, i.e. it controls access to the mysql engine, not the user. This is why, whenever I want to do an import, I execute thusly: # mysql -u mysql -p < script_to_load_file Again, this may not be 100% requisite, but I'm into error prevention and this pretty much ensure that I won't bump into permissions issues. I don't lke setting a fill to 777 but prefer 755. Others can help with greater accuracy but this may be of some help for the future. Andrew Lietzow The ACL Group, Inc. On Friday 24 May 2002 08:44 am, Menard, Inc. Information Systems wrote: > I figured it out but I'm a bit confused as to why it happened. > I'm running the load as user1. The file resides at > /home/user1/data/filename Permissions: > filename 666 > data 777 > user1 700 > > I had to change permissions on user1 to 777 in order for it to work. If I'm > logged in as that user, why would I have to do that??? > > Thanks > Jake > > -Original Message- > From: Menard, Inc. Information Systems [mailto:[EMAIL PROTECTED]] > Sent: Friday, May 24, 2002 8:26 AM > To: Jay Blanchard; [EMAIL PROTECTED] > Subject: RE: Newbie--Easy data loading question > > > yes. I tried all of these methods: > 1) "//dir1//dir2//file" > 2) "/dir1/dir2/file" > running load from file dir using: > "./file" > ".//file" > > I also check the file permissions and it is all read/write. > I can't remember if I tried to run it using mysqls root yet...that would be > the next step, but I prefer not to go there. > > -Original Message- > From: Jay Blanchard [mailto:[EMAIL PROTECTED]] > Sent: Friday, May 24, 2002 8:22 AM > To: 'Menard, Inc. Information Systems'; [EMAIL PROTECTED] > Subject: RE: Newbie--Easy data loading question > > > did you supply the /full/path/to/the/file/ ? > > -Original Message- > From: Menard, Inc. Information Systems [mailto:[EMAIL PROTECTED]] > Sent: Friday, May 24, 2002 8:15 AM > To: [EMAIL PROTECTED] > Subject: Newbie--Easy data loading question > > > Hello > > Forgive me for being a little naive but. > > I am trying to load a table with a text file using the load data infile > command in mysql. I can do it if I place the > text file in the db directory, but I want it to reside in a different dir. > I am getting the error 13: Can't get stat on > What am I doing wrong?? > > Thank you very much in advance for your help! > > Jake > > > - > 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 -- Andrew Lietzow The ACL Group, Inc. 515-274-0300 v/f 515-710-1955 c - 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: Servers & Tables
Dear Curtis, RE:>> How do I log in and see the table layout and data? How do I create a connection to access the tables and data from my ASPs? The first question is a popular one, asked and answered multiple times in the FAQ's. I would also recommend that you look into a GUI front end, like mySQLMan, very early on. I was very frustrated with MySQL until I fount that package. It is a free download from Gossamer-Threads. I have no vested interest in this company, only a vested interest in being productive with MySQL. Too bad about that Windoze thing, however. Can't get out of it, eh? -- Andrew Lietzow The ACL Group, Inc. - 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 with REPLACE INTO statement syntax
> At 21:27 -0500 5/23/02, Andrew Lietzow wrote: > >Dear MySQL wizards, > >I have two tables, call them a and b. The database structure is > > identical. I want the records in b to overwrite the records in (REPLACE > > INTO) a. > >This is the statement that does NOT work. > >REPLACE INTO a SELECT b.* FROM b WHERE a.field1 = b.field1 > >The field names in A are identical to B. On Thursday 23 May 2002 09:33 pm, Paul DuBois wrote: > The SELECT part has to be a legal SELECT statement, which yours > isn't. (The WHERE part names two tables, but the FROM part names > only one.) Thank you for your reply, Paul. I now have two statements; one which works, one which does not. I do not know why the second will not work. *WORKS to create a new table* INSERT INTO a_copy SELECT a.field1, a.field2, a. field.6, b.field7 FROM a,b WHERE a.field1 = b.field1 My resultant table has the data from b that I wanted to put directly into a but could not (because of MySQL rules regarding manipulation of Two Tables?) and writing back to one of them. Is this the reason that I can't get this next statement to work (returns ERROR 1066 - Not unique table/alias. ) *Does NOT work to replace data in table a * REPLACE INTO a SELECT b.* FROM a, b WHERE a.field1 = b.field1 The FROM part now names two tables, as does the WHERE part. (I'm attempting to follow your curative recommendation). So what is wrong with this statement? I want to read records from one file, write them to another, stepping on the contents of the entire record based on a unique index key value. I have 2215 records with correct data (b) and the key matches a key in a file with 4935 records (a). Is this not feasible with MySQL until version 4.X? Maybe I can just say: REPLACE INTO a FROM b USING (field1) ??? TIA for any help... Andrew Lietzow - 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
Help using CREATE Temporary SELECT from two TABLES--Problem now solved
Dear MySQL Wizards, I discovered a solution that works to resolve this problem. :-) Here are the steps I took. -- 1. At the O/S, I copied the three MySQL files to a new name, a_copy. 2. I used mySQLman to delete an index and then to recreate it. I did this because the system showed zero records in the file even though I knew there were thousands. I figured that I must need to force it to count them all. 3. I put the following in a script file: 4. Next, #mysql -u mysql -p < script_file 5. And bingo, the need I once had is now resolved. I now have a new table with the updated field. Unfortunately, the syntax that I am using for a REPLACE statement DOES NOT work exactly like the INSERT statement, as the documentation leads me to believe, so it's back to the drawing board on that one. We need more examples in the documentation. Does anyone post these? Should mere mortals like I be providing such examples without any quality control? Hope this routine can save someone else time and frustration... Ciao! Andrew Lietzow The ACL Group, Inc. On Wednesday 22 May 2002 09:17 am, Andrew Lietzow wrote: > Dear MySQL wizards, > > Thanks for your help in the past. I'm gaining on it! > > Here is a SELECT statement that does exactly what I want it to do... > > SELECT lml.*, ahs.registrant FROM lml INNER JOIN ahs USING (cultivar) > > OR for a more generic presentation, > > SELECT a.*, b.field7 FROM a INNER JOIN b USING (field1) > -- > And what do I want it to do? Select all fields from a, and one field from > b (field7) for just those records that match the key field1. Don't display > the orginal value for field7 of A but replace that value with what is in B. > This appears to work. > > Let me state this another way. I have one database with two tables, A and > B. There is one identical key field (field1=cultivar) in both databases. > The number of records is not the same but I do have a unique key that is > the same in both tables. Database A has a field (field7=registrant) that > is out of date and I want to UPDATE that data into A. As I understand it, > I can't use an update statement on two tables simultaneously. Remember, > Table B has the correct data and I simply want to create a new table, or > UPDATE that data into A. SO. > > I run the query, the system displays the correct data but I need to write > this out to a new table. When I try... > > "#mysql -u mysql database_name -p < file_with_functioning_select statement" > > ...I simply get a help page for mysql that tells me little. > > How do I create a temporary table with this select statement and then write > the temporary table out to disk so that it becomes permanent? > > Alternatively, I might be able to use a JOIN statement but I can't use this > with the mySQLMan, of which I am aware. > > TIA for any help, > > Andrew Lietzow > The ACL Group, Inc. > > On Saturday 18 May 2002 11:41 am, mySQL list wrote: > > Hi, hope somebody can help me - what I want to do is simple I'm sure, but > > I can't work out how to do it: I want to replace a column in a table, > > containing text, with a key to another new table which holds the text. > > > > Example: > > > > Given a table, 'people', which contains two columns, name, and town, like > > this: > > > > name town > > ---- > > fred london > > joliverpool > > amy chicago > > mary chicago > > > > I create a new table, towns: > > > > townidtown > > -- > > 1 london > > 2 liverpool > > 3 chicago > > > > So far good. Now I want to add a townid column to 'people', and update to > > point to the corresponding row in 'towns'. I add a new column, townid, > > but then how do I update the values?? I have tried both of these: > > > > UPDATE people SET people.townid = towns.townid WHERE > > people.town=towns.town; > > > > and > > > > UPDATE people INNER JOIN towns ON people.town = towns.town SET > > people.townid = towns.townid; > > > > mysql gives syntax errors in both cases (both work ok with access 2000). > > > > Is there a way to do this without creating temporary intermediate tables? > > > > Any help greatly appreciated! > > > > > > > > - > > Before posting, please check: > >http://www.mysql.com/manual.php (the manual) > >http://lists.mysql
Re: can't connect to server
Dear Hoa, RE>>> I have the mysql server running. I can't connect to it though. It reads, > "Can't connect to local MySQL server through socket > '/var/lib/mysql/mysql.sock'. - Stop it, (either mysqld or mysql), then start again. On my servers, the mysql startup script is in /etc/init.d and /etc/rc.d/init.d. You enter ./mysql stop as root. DO this in order to actually see the daemon stop and start again. WIth Linux, you should see a message that states that it is [done]. If you still get errors, send the syntax of how you are attempting to connect, after you do the following. (You'll have to know your root password). #mysql -u root -p The system will prompt you for the password. If this you have not changed the password, then it is null so just hit enter. Otherwise, simply enter your password and press enter. When you have the mysql> prompt, then type without the <>. The sytem will show you are connected to the mysql database, and give a connection number. Type and then . Now go to the online documentation and read at least three or four chapters. Create a few tables, do some simple selects, then come back here for your next assignment. :-) Ciao! Andrew Lietzow The ACL Group, Inc. On Thursday 23 May 2002 12:33 am, you wrote: > Hello, > > I have the mysql server running. I can't connect to it though. It reads, > "Can't connect to local MySQL server through socket > '/var/lib/mysql/mysql.sock'. > > -Hoa > > _ > MSN Photos is the easiest way to share and print your photos: > http://photos.msn.com/support/worldwide.aspx > > > - > 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 -- Andrew Lietzow The ACL Group, Inc. 515-274-0300 v/f 515-710-1955 c - 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: php+apache+mysql installation. Help!
Dear Andy, Here's a thought. Before you go much further, install Apache 2.0.36. It's easy to install and lots of improvements will be gained that you'll appreciate down the road, i.e. mod_ssl is preconfigured into the system. Andrew Lietzow The ACL Group, Inc. On Thursday 23 May 2002 06:33 pm, you wrote: > Hi, > > I am new to linux and trying to install Apache, php and mysql on my Redhat > 7.2.Linux box. When I run the configure for PHP 4.2.1, I got this error: > > checking whether build environment is sane..configure error:newly created > file is older than distributed files! > > I have Apache 1.3.20 (from RH 7.2) and Mysql 3.23.49a installed on my box. > Would appreciated if some one could advise how to install PHP. Thanks > > P.S. > I have start Mysql manually. How do I make it auto start and shutdown? > > > > > > _ > MSN Photos is the easiest way to share and print your photos: > http://photos.msn.com/support/worldwide.aspx > > > - > 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 -- Andrew Lietzow The ACL Group, Inc. 515-274-0300 v/f 515-710-1955 c - 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
Help with REPLACE INTO statement syntax
Dear MySQL wizards, I have two tables, call them A and B. The database structure is identical. I want the records in B to overwrite the records in (REPLACE INTO) A. This is the statement that does NOT work. REPLACE INTO a SELECT b.* FROM b WHERE a.field1 = b.field1 I also tried this with the last the conditional statement reversed. MySQL doesn't like my syntax. The field names in A are identical to B. TIA for any help. -- Andrew Lietzow The ACL Group, Inc. - 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 a newbie please
See below... On Monday 20 May 2002 10:33 pm, Hoa Doan wrote: > Hi, > > Please don't kill me. I want to learn about databases. I hear MySQL is a > good start. I have RedHat Linux and I've download and (I believe) > installed mysql. > > Okay, my questions are? What is the difference between the mysql server > and the client program? Do I need both? What is the role of the server > and what is the role of the client program? How do I start inputing data > into the database? > > Thanks in advance for your help. > > Hoa Dear Hoa, the newbie... MySQL is simply one of the many SQL implementations. You run the server on a server, and the client runs on an access/workstation, as in anything that can access the server. In my opinion, without a GUI front end, it is sorely limited in what it can attain in the marketplace for market penetration. However, with that said, the version that comes at no charge is robust, powerful, and quick. To take advantage of this, however, you're going to need to invest heavily in a steep learning curve. I have JUST started gaining benefits and that is only because I decided I HAVE to implement the GUI front end. IF MySQL is distributing a new client front end, I am unaware of that product. I am beginning only recently to accomplish anything worthwhile through writing Perl scripts which access the MySQL database through DBI.All of these are VERY unforgiving--one typo, one comma misplaced, etc. and you're hosed. And, unfortunately, the state of the art in debugging is unbelievably poor, but you can muck your way through. Maybe I am retarded, but that has taken me some time to break through the paradigm shift I had to do (having only worked with Cobol, Fortran, and extensivley with Business Basic). How long is some time? It is a "while..." The languages of the net are very C and C++ oriented, at least the GNU implementations. I had to slow down and first learn something about classes, objects, and methods, and then a bit about scalars, arrays, and hashes. Not a lot, mind you, but enough that they no longer intimidate me. Then I purchased and have read many books--the Perl Black Book, Apache, Linux, the Perl DBI, Perl and CGI, the RedHat Interchange Development Guide, etc. The biggest hurdle, of course, is knowing even WHY you are doing this. What do you want to accomplish with MySQL? If it for a net application, as in an ecommerce system, then the learning curve will be intensive, as in months if not years. If is to just install MySQL to see what the database can do, I would HIGHLY recommend an admin front end, such as mySQLMan from Gossamer-Threads. Don't do anything else until you install something like this or the phpMyAdmin program (I still haven't made that one work). Both of these are free and very useful. If you want to see it in action, go to http://hostahaven.com, click on What's New, then go to the database links. Keep in mind that I'm only crawling, only recently being able to stand erect. For immediate productivity, I found Mohammed J. Kabir's book on RHL 6 very helpful in his section on MySQL. That book, coupled with the mySQLMan for Gossamer-Threads is how I really got going. Of course, for the thousands of records there, I had to thorougly understand CSV data, MS-Access, and a spreadsheet (Excel is what I used), all relatively trivial compared to MySQL. I believe Paul Dubois also has a great book out that comes highly recommended. I imagine that book will be next in my repertoire, but you might want to make it your first. Skip all the agony and pain I went through and just buy the book. BTW, if you go to the MySQL documentation pages, check out the Dynamic Help section, and the chapters offered in HTML through your browser. Maybe you'll get so good so quickly that you can come back here and help people like me with technical questions! Good luck! Oh, and no one here will kill you. Flame you, maybe, but not "kill you". Ciao! Andrew Lietzow The ACL Group, Inc. - 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
Help needed with CREATE Temporary Using SELECT TO TWO TABLES
Dear MySQL wizards, Thanks for your help in the past. I'm gaining on it! Here is a SELECT statement that does exactly what I want it to do... SELECT lml.*, ahs.registrant FROM lml INNER JOIN ahs USING (cultivar) OR for a more generic presentation, SELECT a.*, b.field7 FROM a INNER JOIN b USING (field1) -- And what do I want it to do? Select all fields from a, and one field from b (field7) for just those records that match the key field1. Don't display the orginal value for field7 of A but replace that value with what is in B. This appears to work. Let me state this another way. I have one database with two tables, A and B. There is one identical key field (field1=cultivar) in both databases. The number of records is not the same but I do have a unique key that is the same in both tables. Database A has a field (field7=registrant) that is out of date and I want to UPDATE that data into A. As I understand it, I can't use an update statement on two tables simultaneously. Remember, Table B has the correct data and I simply want to create a new table, or UPDATE that data into A. SO. I run the query, the system displays the correct data but I need to write this out to a new table. When I try... "#mysql -u mysql database_name -p < file_with_functioning_select statement" ...I simply get a help page for mysql that tells me little. How do I create a temporary table with this select statement and then write the temporary table out to disk so that it becomes permanent? Alternatively, I might be able to use a JOIN statement but I can't use this with the mySQLMan, of which I am aware. TIA for any help, Andrew Lietzow The ACL Group, Inc. On Saturday 18 May 2002 11:41 am, mySQL list wrote: > Hi, hope somebody can help me - what I want to do is simple I'm sure, but I > can't work out how to do it: I want to replace a column in a table, > containing text, with a key to another new table which holds the text. > > Example: > > Given a table, 'people', which contains two columns, name, and town, like > this: > > name town > ---- > fred london > joliverpool > amy chicago > mary chicago > > I create a new table, towns: > > townidtown > -- > 1 london > 2 liverpool > 3 chicago > > So far good. Now I want to add a townid column to 'people', and update to > point to the corresponding row in 'towns'. I add a new column, townid, but > then how do I update the values?? I have tried both of these: > > UPDATE people SET people.townid = towns.townid WHERE > people.town=towns.town; > > and > > UPDATE people INNER JOIN towns ON people.town = towns.town SET > people.townid = towns.townid; > > mysql gives syntax errors in both cases (both work ok with access 2000). > > Is there a way to do this without creating temporary intermediate tables? > > Any help greatly appreciated! > > > > - > 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 -- Andrew Lietzow The ACL Group, Inc. 515-274-0300 v/f 515-710-1955 c - 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
Search Query input works, but gives a blank page for results?
The following script, with some edits, has allowed access to a "LOCAL" mysql database. I have reworked it some to access a MySQL on another server I suppose I could transfer the script to that server for loading/execution, but I'd like to learn how one accesses a remote mySQL database (to facilitate building a shopping cart system. Anyhow, when it executes, I can select the field I want to search on from a popup_menu, select "is" or "contains" and then enter the text I wat to search for. That part works. What doesn't work is that I receive simply a blank page for a display (all this beautiful color of 738C8C). Have I got the syntax for access to a remote database correct? TIA for any help... - #!/usr/bin/perl -w # CGI to select data from a SQL database use CGI; use strict; use DBI; my $q = new CGI; #Definitions -unique to each table, user, etc. my $db = "the_plant_database"; my $table = "da_table"; my $host = "201.201.201.21"; my $user = "mysql"; my $password = "mypassword"; # This is the main branch. The first time through # display the form to the user; when the user submits # the form then we process the input if ($q->param('field') eq "") {&printform()} else {&results()} sub printform { print "Content-Type: text/html\n\n"; # print $q->header; print $q->start_html(-title=>'MySQL Plant Database at Plants.com', -BGCOLOR=>'#738C8C', -TEXT=>'white'); print "MySQL Plant Search - Da_List of Plants"; print $q->startform; print "Plants that match selection"; print $q->popup_menu(-name => 'field', -values => ["ML_ID", "Cultivar", "Reg_Status","Section","Class","ML_ITG_ID","Registrant"], -default=> "Cultivar"); print $q->popup_menu(-name => 'searchtype', -values => ["is", "contains"], -default=> "is"); print $q->textfield(-name =>"text", -size => 16), ""; print $q-> submit; print $q->endform; print $q->end_html; } sub results { print $q->header(); my $field = $q->param('field'); my $searchtype = $q->param('searchtype'); my $text = $q->param('text'); my @table=(); print $q->start_html(-title=>'Database Results', -BGCOLOR=>'#738C8C', -TEXT=>'white'); # Establish a connection with the database my $dbh = $drh->connect($host, $db, $table, $user, $password); # A simple check to see if we connected if (!$dbh) { print "Cannot connect: $DBI::errstr"; print $q->end_html; die; } # Build and execute the SQL statement my ($SQLstatement); if ($searchtype eq "contains") { $SQLstatement = "select ML_ID, Cultivar, Reg_Status, Section, Class, ML_ITG_ID, Registrant from $table where $field like \"%$text%\""; } else { $SQLstatement = "select ML_ID, Cultivar, Reg_Status, Section, Class, ML_ITG_ID, Registrant from $table where $field = \"$text\""; } my $sth = $dbh->prepare($SQLstatement); my $howmany = $sth->execute; # Display an error message if we can't find any matches if ($howmany eq "OEO") { print $q-h3(" Couldn't match $text in database"); die; } print "$howmany matches found in database"; push (@table,$q->th(["ML_ID", "Cultivar", "Reg_Status", "Section","Class","ML_ITG_ID","Registrant"])); # Loop through all the matches and store them in @table for (my $i = 0; $i < $howmany; $i++) { my ($SQLML_ID, $SQLCultivar, $SQLReg_Status, $SQLSection, $SQLClass, $SQLML_ITG_ID, $SQLRegistrant) = $sth->fetchrow_array; push (@table,$q->td([$SQLML_ID, $SQLCultivar, $SQLReg_Status, $SQLSection, $SQLClass, $SQLML_ITG_ID, $SQLRegistrant])); } # Print the table of data we received from the mySQL database. print $q->table({-border => 1, -align => "center"},$q->TR(\@table)); print $q->end_html; } -- Andrew Lietzow The ACL Group, Inc. - 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
Script fails during MySQL access attempt.
Dear MySQL wizards, Perhaps this is more of a Perl question than a mySQL question but I am trying to access a mySQL database. Here is the line of code. if ($q->param('field') eq "") {&printform()} else {&results()} This gives the reply: Use of unitialized value in string eq at select.cgi line 18. main::(select.cgi:18): if ($q->param('field') eq "") {&printform()} else {&results()} Any ideas where I can find what is wrong with this code? Or a better way to access a mySQL database with a Perl Script? Examples? TIA, -- Andrew Lietzow The ACL Group, Inc. - 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 with UPDATE and SET with two tables
On Tuesday 14 May 2002 06:10 am, Egor Egorov wrote: > If not, can I write the Query results of the SELECT statement out to a > new table and delete the original table? > > Yes, you can use CREATE ... SELECT statement. Thank you for the reply, Egor. Here is what I have tried since your reply but it doesn't like my syntax connect hostas; CREATE TABLE hostas_01 (UNIQUE(Cultivar)) SELECT LML.ML_ID LML.Cultivar LML.Reg_Status LML.Section LML.Class LML.ML_ITG_ID LML.Reference AHS.Registrant FROM LML INNER JOIN AHS USING (Cultivar); To look at the actual data, go here http://dev.hostahaven.com/cgi-bin/mysqlman/mysql.cgi use host = localhost User = hostas Password = hostas (I hope I have the security high enough that nobody will steal my hostas!) Select the hostas database. You'll see the LML table and the AHS table. What I want to do is move the value for "Registrant" in the AHS table to Registrant in the LML table (using Cultivar at the record key). If I can do that with a JOIN statement WITHIN the mySQLMan package, I don't know how, and unfortunately, I have not been able to get the phpMyAdmin to load So, that is where I am. I'm trying to avoid exporting to a spreadsheet or another language -- I want to do this all within MySQL, if possible... That's my problem. TIA for any help... -- Andrew Lietzow The ACL Group, Inc. - 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
Help with UPDATE and SET with two tables
Dear MySQL Wizards, I have a database with several tables. I want to update a field in that table with a field contained in another table. I have a unique key to use for a WHERE clause. This is easy to do with various procedural languages (Business Basic, for one) but I don't find much info in MySQL documentation for doing this, other than the UPDATE command (which produces an error, see below). I want to open a file, read a record, retrieve another record based on a key value in the previously read record, change the values appropriately, and then write the updated record back out. ? I have been successful at running a SELECT like this: connect database; SELECT A.*,B.Registrant from A INNER JOIN B USING (Cultivar); This gives me a listing to the screen that looks like it worked. Now I'd like to update the table A with what comes from table B (for the field called Registrant, present in both tables). UPDATE A SET A.Registrant=B.Registrant WHERE A.Cultivar=B.Cultivar; When I execute this statement, I get an error that it can't find the second table in the database but I know it is there--I can access, browse, update records in that table, etc. It seems like this should be a common thing to want to do but a gentleman yesterday on the SuSE list said that this may not be possible with MySQL. If not, can I write the Query results of the SELECT statement out to a new table and delete the original table? TIA for any help. Andrew Lietzow The ACL Group, Inc. - 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
Thanks to whomever... for the tip on mySQLMan...
Helo list, I don't recall if it was here that I heard of this mySQLMan package. I think so. http://www.gossamer-threads.com/scripts/mysqlman/index.htm has quickly saved me lots of hair, and will soon enable me to go live with mySQL... My use and interest in mySQL has just taken a quantum leap forward. I have known for a long time that I would eventually want to run mySQL but the inability to use a web browser to access and manipulate data was a show-stopper for me. I just could not see myself getting all that excited by a character-based interface. It works for some things but not for serious database development, IMO. Last time I checked, Oracle wanted about 1,000,000 US dollars for their front-end gizmo (Oracle Forms?). I'm sure it has come down some since I checked. And maybe there is an X-Windows GUI interface available, but I am not aware of it. I have worked with 3-GL's in character based mode for over a decade; I like being spoiled by a browser and a GUI. So, I waited and waited, and voila, someone finally invented the wheel. The only thing I KNEW for sure during this time was that I was not going to give in and begin to use a MS product like Access; one that runs only on Windoze based O/S's. There are lots of great products for Windoze and I have to hand it to MS for marketing, but I'm not interested in having to reboot and reboot just to regain resources with a production system. While there are lots of users of MS-Access, it doesn't come in a Linux flavor so I could not devote much of my mindshare to it. It is an unfortunate reality because I really need a good database but it had to run on Linux to get my attention. So, now that I have found mySQLMan, I owe someone a huge "Thank you!". I got it up and running in a day, or so, and I'm excited to be moving on with my little project. I do get the impression that mySQL is compatible with RH Interchange as the install asks this question during setup. Hope that proves to be true. If there is a better way to go for an ecommerce server than Interchange, I have not seen it--but I'm all ears! Any caveats or alternative recommendations would be considered but only for a short time...I'm about to attain lift off! Personally, I do think the security issues on mySQL take up an inordinate amount of time (from what I can see on this list, it's a major issue that needs revisited from a development point of view). Thankfully, by seeing that there is more than one table involved with the mySQL database, I poked at it long enough that I finally got the remote login to work. Geepers, what a nightmare... Wouldn't it just be easier to hang all of the illegally intruding b*$#(@+s until we eradicated them from the planet? Andrew Lietzow The ACL Group, Inc. alias Number 1 Plantsman at http://hostahaven.com - Original Message - From: "Brian Bray" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 25, 2002 11:35 AM Subject: fulltext server as replication client? > Here is a though: > > I know that replication requires identical table definitions, but does > that also include identical indexes? > > So, could I setup a master database without a fulltext index on a > particularly large table I have and then setup a slave server with the > fulltext index and then do all the fulltext queries on the slave server? > > > Thanks, > Brian Bray > > > > [for the filter: sql,query] > > > - > 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: Access denied for user: (from perl script)
Hello list, I am attempting to run: >perl -MCPAN -e 'install DBD::mysql'< I am having a similar problem as the message that is in this subject line, reported by Jon Ingason in a message dated March 1, 2002. I must have tried the install routine at least 15 times, varying different settings that I thought would force the system to use a different test file, fix permissions, etc. I even installed a new mysql and Perl, but all efforts have produces no better results. I get an unable to connect error. It gets through most of the install routine just fine, until attempting to access the test database. I didn't know whether the test database should be created or not, but I've tried it both ways. Then I switched to having the system use the database which I know I can access at the command line to add records and privileges. At first, I thought it was due to a GRANT PRIVILEGES issue, so I spent quite a bit of time making sure that the database was accessible, passwords were set up correctly, etc. The DBD file is DBD-mysql-2.1011. Should I be using >Bundle::DBD:mysql< ? Would that make this setup routine any easier? If the database is accessible at the command line, why would it not be unable to connect when using the perl install routine? TIA for any help. Andrew Lietzow The ACL Group, Inc. [EMAIL PROTECTED] - 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