Click to See Complete Forum and Search --> : insert # sign to mysql and also pass it through ajax url
niladhar8@gmail.com
March 30th, 2010, 03:16 PM
How can i insert # sign into the database? Do i have to use a different collation?
Also cannot pass both & and # signs through the ajax url to the php file, any work around that excepting for replacing it with delimiters?
PeejAvery
March 30th, 2010, 06:24 PM
Remember that & and # are URL string delimiters. You have to URL encode/decode them.
niladhar8@gmail.com
March 31st, 2010, 10:30 AM
Remember that & and # are URL string delimiters. You have to URL encode/decode them.
How would i do that?
I mean lets say in my query i have a certain text field which contains #
$qry = "insert into xyz values(null, '#1 Fan Image')";
Do you mean i should urlencode('#1 Fan Image'); ??
and while retrieving it decode it?
would it have an adverse effect if the string did not contain any special characters, i mean i donot want to search for a special character and encode it only on its existance.
PeejAvery
April 1st, 2010, 09:53 AM
Use JavaScript's encodeURI() to pass it through the AJAX call. Then, use PHP's urldecode() on just the variable for the query string.
niladhar8@gmail.com
April 2nd, 2010, 11:46 AM
Use JavaScript's encodeURI() to pass it through the AJAX call. Then, use PHP's urldecode() on just the variable for the query string.
encodeURI seems to work only for urls. But my issue is if i am passing some to be inserted into the db on an ajax call i would want the user to put in special characters like # and & as well. using encodeURI is not good for this.
PeejAvery
April 3rd, 2010, 09:39 PM
encodeURI seems to work only for urls.
So are you only sending as POST and not GET?
i would want the user to put in special characters like # and & as well. using encodeURI is not good for this.
encodeURI would not affect inputing special characters into the database at all if you remembered to decode them on the server-side...as I suggested.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.