1. mysql add records

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

new topic     » topic index » view message » categorize

2. Re: mysql add records

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: mysql add records

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

new topic     » goto parent     » topic index » view message » categorize

4. Re: mysql add records

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: mysql add records

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')

new topic     » goto parent     » topic index » view message » categorize

6. Re: mysql add records

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".

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu