![]() |
| Concatenating strings in cgi - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Concatenating strings in cgi (/thread-20733.html) |
Concatenating strings in cgi - Meera2019 - Aug-28-2019 I am using Python 3.4. I was working on cgi programming. I created checkboxes and wanted to get those input values as string and post it in single field in MySQL database. When I add strings in IDLE as normal program I get output, but in cgi same code produces error as bad headers. HTML code: Select hobbies</td><td>Books<input type="checkbox" name="books" value="books">Crafts<input type="checkbox" name="crafts" value="crafts">Tailoring/Embroidery<input type="checkbox" name="tailor" value="tailoring"> <python> import cgi form1 = cgi.FieldStorage() books = str(form1.getvalue('books')) crafts = str(form1.getvalue('crafts')) tailor = str(form1.getvalue('tailor')) hobbies = books + crafts + tailor print (hobbies) </python> hobbies variable gets printed, whereas the browser throws error as bad header for the above code where concatenate three strings RE: Concatenating strings in cgi - metulburr - Aug-28-2019 When you print in CGI the first character must be the header Content-type: text/html\nFollowed by an empty line Then your content https://python-forum.io/Thread-Run-Python-CGI-from-Apache RE: Concatenating strings in cgi - Meera2019 - Aug-31-2019 Oh thank you, metulburr, for that. Yeah, the error was removed. |