| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() | Injection (php-mysql) I have got a problem with a character. I do not know which one it is. I am inserting long text files into database and sometime i can not insert. Any idea which character can it be? I am using this code PHP Code: |
| |
| | #2 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | The easy way to fix this problem is to use mysql_real_escape_string() on your input this will ensure that any relevant characters are escaped. Oh and by the way stop using addslashes it is far from ideal, if you use the above mentioned function then the addslashes function is not needed (and can cause problems) anyway. I would also check and see if you have magic_quotes_gpc enabled (most hosts do). If that is the case reverse what this feature does or disable it using a .htaccess file if you are able too. In fact while you are at it disable register_globals.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #3 (permalink) |
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() | PHP Code: thanks |
| |
| | #4 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | yes thats fine, just a note I do not know what the content of $type should be but you should run the function on that as well.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #5 (permalink) |
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() | it did not work. Same problem. then i used this code but same problem again. I do not know if this code is ok PHP Code: |
| |
| | #6 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | echo out the query and post it here, also a copy of the error message you receive. Ahh and just noticed. Do the mysql_real_escape_string lines after the following not before, i never noticed it before:- PHP Code:
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #7 (permalink) |
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() | This is the code i used PHP Code: Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. |
| |
| | #8 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | That seems completely unrelated.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #10 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | invalid characters should not cause a Service Temporarily Unavailable if it does then there is something seriously wrong.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #12 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Why are you replacing them with a space? They will not be causing you any problem and in fact you are losing formatting by doing this.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | #14 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | it shouldn't do, mysql_real_escape_string takes into account the charset that is in use. Anyway if the charset was the problem you should see a mySQL error being generated.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft
Last edited by peter@flexiwebhost; 11-23-2007 at 04:31 PM.
|
| |
| | THREAD STARTER #17 (permalink) |
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() | I think i am going to use PHP Code: I do not think it will be a problem. |
| |
| | THREAD STARTER #19 (permalink) | ||||
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() |
PHP Code: | ||||
| |
| | #20 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | i cant see why having the string wget would cause problems unless you were running it through exec or something like that.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #21 (permalink) | ||||
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=399017 I deleted that word from the post and it worked fine. I tried to enter onlt the word "wget " and it fails. | ||||
| |
| | THREAD STARTER #24 (permalink) | ||||
| NamePros Member Join Date: Jan 2007
Posts: 98
![]() |
I just made a simple script to try one by one if the problem is "wget " I can insert "wget" but not "wget " here is the simple code i am using. PHP Code: Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. | ||||
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |