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

3
  • Why not direct to the database, via the databases API? Commented Aug 20, 2011 at 2:49
  • because i'm new to c++ and didnt know there is something like that Commented Aug 20, 2011 at 8:15
  • possible duplicate of connect to mysql using c++ Commented Aug 20, 2011 at 12:36

5 Answers 5

1

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

Sign up to request clarification or add additional context in comments.

Comments

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/

3 Comments

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 : pastebin.com/TLjDRJXD
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 : /
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.

Comments

0

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

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.