I am importing different text files into the database, it is only inserting data until we get a qutoe or some other character then alphabet like this
Adsense is all about targeted content, the more targeted your content is, the more target the search engines’ ads will be. It will stop at engines.
Another example is With the real-time reporting at hand, HERE It WILL STOP AT real
I have tried different options to escape single quotes etc but this is not normal singl quote like ' its a comma on top, what to do to skip all characters like these.
Thanks,
Atiq
Esacaping character issue while inserting into mysql
Moderator: General Moderators
Re: Esacaping character issue while inserting into mysql
I have already tried that function and did some more but it didn't work. It does work locally but its not working on live server.
Query is this:
$sql = "UPDATE sn_posts set post_content = '".htmlspecialchars(mysql_real_escape_string($buf))."' WHERE ID = '".$post_id."'";
$buf is the variable that is getting data from text file.
Can it be a server configuration issue.
Atiq
Query is this:
$sql = "UPDATE sn_posts set post_content = '".htmlspecialchars(mysql_real_escape_string($buf))."' WHERE ID = '".$post_id."'";
$buf is the variable that is getting data from text file.
Can it be a server configuration issue.
Atiq
Re: Esacaping character issue while inserting into mysql
Please read my message above, also i looked and it escapes based on characterset, we have currently utf8 both locally and on server.
\$db['default']['char_set'] = 'utf8';
\$db['default']['dbcollat'] = 'utf8_general_ci';
Its same to the server but still it doesn't work on server, can i try some thing else? Where can i check character set of the database it self?
Regards,
Atiq
\$db['default']['char_set'] = 'utf8';
\$db['default']['dbcollat'] = 'utf8_general_ci';
Its same to the server but still it doesn't work on server, can i try some thing else? Where can i check character set of the database it self?
Regards,
Atiq
Re: Esacaping character issue while inserting into mysql
You should not use htmlspecialchars() on strings that are to be inserted in an SQL query, only on strings that are to be outputted as HTML.atiq576 wrote:Query is this:
$sql = "UPDATE sn_posts set post_content = '".htmlspecialchars(mysql_real_escape_string($buf))."' WHERE ID = '".$post_id."'";
Even if you intend to do htmlspecialchars() on strings that are stored in your database (as a sort of cached pre-formatting measure, so you can retrieve them later and output as HTML directly, without doing htmlspecialchars at that time) then still you should ALWAYS apply mysql_real_escape_string() last. This holds for any other functions besides htmlspecialchars as well.
Remember: mysql_real_escape_string() makes a string suitable to be used in a query. Any other function, such as htmlspecialchars, may (and should be assumed to) mess this up, making the string no longer trustworthy to include in SQL queries.
Re: Esacaping character issue while inserting into mysql
$sql = "UPDATE sn_posts set post_content = '".mysql_real_escape_string($buf)."' WHERE ID = '".$post_id."'";
As you can see above I removed the htmlspecialchars function from the query now but it still doesn't insert the full string. I am attaching a smaple file that I am testing it with
Below I am copying the paragraph that I have in file that I m importing and getting issue:
Adsense is all about targeted content, the more targeted your content is, the more target the search engines’ ads will be. There are some web masters and publishers who are focused more on their site contents and how best to maintain them rather than the cash that the ads will generate for them. This is the part where the effectiveness is working its best.
The insert stope after search engines.
Please advise.
Thanks,
Atiq
As you can see above I removed the htmlspecialchars function from the query now but it still doesn't insert the full string. I am attaching a smaple file that I am testing it with
Below I am copying the paragraph that I have in file that I m importing and getting issue:
Adsense is all about targeted content, the more targeted your content is, the more target the search engines’ ads will be. There are some web masters and publishers who are focused more on their site contents and how best to maintain them rather than the cash that the ads will generate for them. This is the part where the effectiveness is working its best.
The insert stope after search engines.
Please advise.
Thanks,
Atiq
Re: Esacaping character issue while inserting into mysql
Don't you get any error messages?
Try view source and see if it's an mySQL error message in there.
I suspect some server configuration issue. Plus, did you check if magic_quotes etc are set to Off?
Try view source and see if it's an mySQL error message in there.
I suspect some server configuration issue. Plus, did you check if magic_quotes etc are set to Off?