Hi, all!
I'm working on a system which allows me to send data to my php page which puts the data into mysql, so far so good, I am able to establish a connection with the php page when I use a static char as url path. Though, I would like to have the url adapt to the variables when a RFID tag is read. Thus, i started thinking about how to construct this and came up with a char for each parameter and combine them together by making use of strcat. Unfortunately, until now it doesn't seem to work, when I print my url char it's completely empty and thus I'm unable to get a return char.
The strcat I've constructed:
char* pre_url[]={"/add_db.php?register="};
char* register[]={"StalKennetW", "StalKrawall", "Stapmolen", "Dressuurbak"};
char* mid_url1[]={"&name="};
char* name[]={"KennetW", "Krawall"};
char* mid_url2[]={"&date="};
char* date[]={"lipsum"};
char* mid_url3[]={"&time="};
char* time[]={"dolor"};
char url[300]; // enough room for all strings together
char* concat(char* pre_url, char* register, char* mid_url1, char* name, char* mid_url2, char* date, char* mid_url3, char* time) {
url[0] = 0; // start with a null string:
strcat(url, pre_url); // add first string
strcat(url, register);
strcat(url, mid_url1);
strcat (url, name);
strcat(url, mid_url2);
strcat (url, date);
strcat(url, mid_url3);
strcat (url, time);
return url;
}
The following step would be to chose a specific name from the char to put in the url, I guess it would look as following, though I get an error which says my int's aren't declared, which is weird. Because they are. Thus I guess I will probably do something terrible wrong or I'm thinking to difficult.
char* pre_url[]={"/add_db.php?register="};
char* register[]={"StalKennetW", "StalKrawall", "Stapmolen", "Dressuurbak"};
char* mid_url1[]={"&name="};
char* name[]={"KennetW", "Krawall"};
char* mid_url2[]={"&date="};
char* date[]={"lipsum"};
char* mid_url3[]={"&time="};
char* time[]={"dolor"};
char url[300];
char* concat(char* pre_url, char* register[id], char* mid_url1, char* name[name], char* mid_url2, char* date[date], char* mid_url3, char* time[time]) {
url[0] = 0; // start with a null string:
strcat(url, pre_url); // add first string
strcat(url, register[id]);
strcat(url, mid_url1);
strcat (url, name[name]);
strcat(url, mid_url2);
strcat (url, date[date]);
strcat(url, mid_url3);
strcat (url, time[time]);
return url;
}
Thanks in advance,
Niels