1. mysql add records
- Posted by Jim Smiley <sixs at ida.net> Apr 10, 2007
- 572 views
- Last edited Apr 11, 2007
HI, I would like to add records to an existing table. I am trying to use run_query. I have an insert statement that adds records to an mysql table using a mysql utility. But I don't have the syntax to run it in Euphoria code--------------------------------------------------- query="INSERT INTO works (works,workid,subjectid,personid) VALUES ('','4',3))" aresult=run_query(query) Is this the correct statement? I have used "mysql_db_query" with no luck Any help will be appreciated! Thanks in advance JIm
2. Re: mysql add records
- Posted by c.k.lester <euphoric at cklester.com> Apr 10, 2007
- 529 views
- Last edited Apr 11, 2007
Jim Smiley wrote: > > query="INSERT INTO works (works,workid,subjectid,personid) VALUES ('','4',3))" > aresult=run_query(query) You have four fields and only three values. Maybe that's the problem. Plus, there's an extra ')' at the end of the SQL.
3. Re: mysql add records
- Posted by Jim Smiley <sixs at ida.net> Apr 10, 2007
- 541 views
- Last edited Apr 11, 2007
Hi, I copied the wrong line . Below is the working code that inserts a record using SQL YOG ----------------- INSERT INTO works (workid,subjectid,personid,title) VALUES ('','1','1','1abc') --------------------------------------- None of these commands seem to work. result=run_query(query1)error says attempt to subscript an atom result=mysql_db_query(query1)missing db or query result=mysql_db_query(query1)error says empty query --------------------------------------------------- JIm
4. Re: mysql add records
- Posted by Chris Burch <chriscrylex at aol.com> Apr 11, 2007
- 551 views
Jim Smiley wrote: > > Hi Don't use the mysql wrapper, but if there's any similarity to sqlite > Hi, > I copied the wrong line . Below is the working code that inserts a record > using > SQL YOG > ----------------- > INSERT INTO works (workid,subjectid,personid,title) VALUES ('','1','1','1abc') query1 = "INSERT INTO works (workid,subjectid,personid,title) VALUES ('','1','1','1abc')" > --------------------------------------- > None of these commands seem to work. > result=run_query(query1)error says attempt to subscript an atom result = run_query(query1, database_to_run_query_on) where database_to_run_query_on is the actual name, or handle, of a previously opened / connected database. > result=mysql_db_query(query1)missing db or query result = mysql_db_query(query1, database_to_run_query_on) > result=mysql_db_query(query1)error says empty query etc Chris > --------------------------------------------------- > JIm http://euallegro.wikispaces.com http://members.aol.com/chriscrylex/euphoria.htm http://uboard.proboards32.com/ http://members.aol.com/chriscrylex/EUSQLite/eusql.html
5. Re: mysql add records
- Posted by c.k.lester <euphoric at cklester.com> Apr 11, 2007
- 536 views
Jim Smiley wrote: > ----------------- > INSERT INTO works (workid,subjectid,personid,title) VALUES ('','1','1','1abc') > --------------------------------------- Okay, are the id fields numbers (not strings)? If so, you'd have to use (0,1,1,'1abc')
6. Re: mysql add records
- Posted by Jim Smiley <sixs at ida.net> Apr 11, 2007
- 539 views
Hi, I tried taking off the quotes and using 0 to replace automatic number. It didn't work. I used the quotes in mysql and they worked. Is the run_query the correct command? I also tried the php mysql command "mysl_query" and I still couldn't get it to work, it says "the query is empty".