SQL Insert Problem
I have column in my database which is clientRemarks and it's defined as TEXT but I have been having errors whenever a client enters remarks such "I'm not doing this" but if a client enters "I am not doing this". It's fine. Please help. The error occurs whenever a client complete a form online on the website. coding was done with php and MySQL for the website.
Thanks
Thanks
I think your question may be answered by this tutorial on CodeFixer - the apostrophe bug.
James Coltham - Local gov web manager by day, web and accessibility blogger at lunchtime, freelancer by night. Tweets at @prettysimple.
| Codefixer wrote: |
| To allow an apostrophe mark to be inserted into a database, simply double-up all occurences of the apostrophe mark. SQL will see two apostrophes together and treat them as a single apostrophe and at the same time realise that this doesn't signify the end of the string. |
James Coltham - Local gov web manager by day, web and accessibility blogger at lunchtime, freelancer by night. Tweets at @prettysimple.
Hi James,
Thanks for your reply, the example in code fixer was for asp. How do i implement with PHP? this is my first experience of coding in PHP.
Thanks
Tolani
Thanks for your reply, the example in code fixer was for asp. How do i implement with PHP? this is my first experience of coding in PHP.
Thanks
Tolani
Hi teelan,
A word of general advice: you should never ever put user input directly into an SQL query, or you could be subject to an SQL injection attack. There's a good Wikibook about SQL injection, and the final suggestion (parameterised statements) coupled with regular expression validation sounds like the best approach for PHP. I strongly recommend you investigate this! It should also fix your apostrophe problem.
A word of general advice: you should never ever put user input directly into an SQL query, or you could be subject to an SQL injection attack. There's a good Wikibook about SQL injection, and the final suggestion (parameterised statements) coupled with regular expression validation sounds like the best approach for PHP. I strongly recommend you investigate this! It should also fix your apostrophe problem.
Hi teelan,
If you want to insert the apostrophe mark into a database then you have to double the occurrence of apostrophe. I had tried this, It really works.
If you want to insert the apostrophe mark into a database then you have to double the occurrence of apostrophe. I had tried this, It really works.
Try this query
INSERT INTO TABLE tablename VALUES (VALUE)
or you would not have given the specific format for your data
INSERT INTO TABLE tablename VALUES (VALUE)
or you would not have given the specific format for your data
Maybe it would be good to use some OCR - but I am not sure if it is any for PHP. In Java you are using Hibernate or iBATIS and you forget about the problem.
you just need add slashes
| Code: |
| "INSERT INTO TABLE tablename VALUES (".addslashes($_POST['input']).") " |
| schoolwebdesign wrote: | ||
you just need add slashes
|
thanks a lot
Try SQL insert query
INSERT INTO TABLE tablename VALUES (VALUE)
if still have issues then please reply
INSERT INTO TABLE tablename VALUES (VALUE)
if still have issues then please reply
i agree with kemon and every person "INSERT INTO TABLE TABLENAME VALUES()"



