php - Linker error using wininet in c++ -


i'm going upload data using wininet in c++.
here code.

        #include "stdafx.h"     #include "iostream"     #include "windows.h"     #include "wininet.h"     #include "tchar.h"     #include "iostream"     #include "string"     #include "sstream"      #pragma comment(lib, "ws2_32.lib")      int main(){              tchar hdrs[] = _t("content-type: application/x-www-form-urlencoded");     tchar frmdata[] = _t("name=john+doe&userid=hithere&other=p%26q");     lpctstr accept[] = {_t("*/*"), null};      hinternet hsession = internetopen(_t("myagent"), internet_open_type_preconfig, null, null, 0);     hinternet hconnect = internetconnect(hsession, _t("http://localhost"), internet_default_http_port, null, null, internet_service_http, 0, 1);     hinternet hrequest = httpopenrequest(hconnect, _t("post"), _t("/upload.php"), null, null, accept, 0, 1);     httpsendrequest(hrequest, hdrs, _tcslen(hdrs), frmdata, _tcslen(frmdata));          return 0;          } 

i using visual studio 2012 compiling it.
compile in dev c++ error same.

1>asdfg.obj : error lnk2019: unresolved external symbol __imp__internetopenw@20 referenced in function _main

1>asdfg.obj : error lnk2019: unresolved external symbol __imp__internetconnectw@32 referenced in function _main
1>asdfg.obj : error lnk2019: unresolved external symbol __imp__httpopenrequestw@32 referenced in function _main
1>asdfg.obj : error lnk2019: unresolved external symbol __imp__httpsendrequestw@20 referenced in function _main

update
i'm using #pragma comment(lib, "wininet.lib") , getting no error.
program compile data not upload.
here php file.

<?php      $name = $_post['name'];     $userid = $_post['userid'];     $other = $_post['other'];      $myfile = fopen("newfile.txt", "w") or die("unable open file!");     $txt1 = $name."\n";     fwrite($myfile, $txt1);     $txt2 = $userid."\n";     fwrite($myfile, $txt2);     $txt3 = $other."\n";     fwrite($myfile, $txt3);     fclose($myfile);     ?> 

you need link against correct library, <wininet.h> wininet.lib.

also, when include system headers wininet.h or sstream.h, should enclose names in < > rather " ", local project files.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -