Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-06

Insert into ... mysql

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

César Espinoza

Hi all !!

I did! I can now connect and query to mysql

fpc 2.2.4, console, Macosx 10.5 leopard, Mac book Intel

But I can't (may be I dont know :-( ) insert data in a table
------------
 connect mysql  ... ok
  select db ... ok
.....
  new(consulta);
  consultastr:='INSERT INTO lugares (lugar) values (''Sala'')';
  strPCopy(consulta,consultastr);
  writeln ('Executing query : ',Consulta,'...');
    if (mysql_query(sock,consulta) < 0) then
      begin
      Writeln (stderr,'Query failed ');
      writeln (stderr,mysql_error(sock));
      Halt(1);
      end;
----------

What is wrong?
Thanks in advance

------- César Espinoza Soto ---------

Reply by email

Henry Vermaak
to César Espinoza

2009/6/28 César Espinoza :

Show quoted text 14 lines
Hi all  !! I did! I can now connect and query to mysql fpc 2.2.4, console, Macosx 10.5 leopard, Mac book Intel But I can't (may be I dont know :-( ) insert data in a table ------------  connect mysql  ... ok   select db ... ok .....   new(consulta);   consultastr:='INSERT INTO lugares (lugar) values (''Sala'')';   strPCopy(consulta,consultastr);

Is there enough space allocated for consulta to take length(consultastr)+1? Why don't you just use:

mysql_query(sock,PChar(consultastr))?

Henry

Reply by email

John Coppens
to César Espinoza: Hi all !! I did! I can now connect and query to mysql fpc 2.2.4, console, Macosx 10.5…
But I can't (may be I dont know :-( ) insert data in a table

If you can query, but not insert, there are a few things to check:

- Is the syntax of your insert correct? I mean, does column 'lugar' exist, and is it a varchar column, etc.?
- Are you allowed to insert? (Check the privileges for the person as who you log in. Insert, update, select, all have separate 'enables')
- What is the message returned by mysql_error?

John

Reply by email