0

I would like to send data from my C++ app to a database via HTML form or just by and address in PHP script like index.php?mydata=something. I'm trying to do this because sending an email from C++ was to hard for a beginner like me. I just want to send one string or if it's possible, a file.

Thanks in advance.

EDIT: Or if someone can guide me how to connect directly to the MySQL and insert the data in a specified table i woudl be more than grateful ! : )

EDIT2: I found the mysql api and have all the libraries and mysql header but i have problems with connecting to the DB. error: unresolved external symbol _mysql_init@4 referenced in function _main code : pastebin.com/TLjDRJXD

shym
  • 299
  • 1
  • 10

5 Answers5

1

use JSON. It has native support in newer versions of PHP.

Adam Fowler
  • 1,750
  • 1
  • 17
  • 18
1

C API for MySQL:

http://dev.mysql.com/doc/refman/5.6/en/dynindex-cfunction.html

http://forge.mysql.com/wiki/Category:C

C++ API for MySQL:

http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html

http://forge.mysql.com/wiki/Connector_C%2B%2B

There are many more, e.g. C++ wrappers for the C API:

http://mysqlcppapi.sourceforge.net/

Steve-o
  • 12,678
  • 2
  • 41
  • 60
  • i found it but i have problems with connecting to the DB. I have the mysql headers and libraries but theres an error: unresolved external symbol _mysql_init@4 referenced in function _main code : http://pastebin.com/TLjDRJXD – shym Aug 20 '11 at 12:23
  • @shym see this question: http://stackoverflow.com/questions/7108740/why-simple-mysql-code-compiles-standalone-but-not-in-project – Steve-o Aug 20 '11 at 12:39
  • the thing is that I had other errors but now i linked everything properly but it still doesent work : / i linked libmysql.lib and the whole folder with headers in MySQL community Server but still doesen't work : / – shym Aug 20 '11 at 17:00
0

It sounds like it might be best to do this with a simple PHP API. This way you can be sure to have a clean and secure connection between your C++ app and the PHP app.

You can Google around to find lots of examples and tutorials.

Matt Stein
  • 3,053
  • 1
  • 19
  • 35
0

The better way is a PHP API but if you are curious you can use IndyProject

tttony
  • 4,944
  • 4
  • 26
  • 41
0

You may find these useful:

What C++ library should I use to implement a HTTP client?

High-level HTTP client library for native C/C++ in Win32

http://curl.haxx.se/libcurl/competitors.html

Basically you can use any C++ http client to send GET/POST requests to your PHP page.

Community
  • 1
  • 1
Viet
  • 17,944
  • 33
  • 103
  • 135