469,307 Members | 1,996 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,307 developers. It's quick & easy.

Trouble with Ajax: can't insert words into mysql with characters like ', e.g. "don't"

angelhiso
hei coild somebody help me with ajax mysql ?
I use ajax to put data to my database but why i can not put the charector like ' \ ? for example i want to put the word DON'T which has the 'it could not do it why ? what should i do ?
Apr 30 '09 #1
7 1612
I can not put the charector like \ ' to the data base.
I use ajax to put the data to my database and i found today that i can not put these kinds of charector to my database at all. every word which contents ' can not be sent for example don't can't \
But when i tried to put the data to database with the normal method (none ajax) so i could do that.
Ajax is cool and quick but how could i fix this problem ? have somebody here the same prblem as me ?
Apr 30 '09 #2
Dormilich
8,651 Expert Mod 8TB
did you escape the values (PHP side)? (e.g. mysql_real_escape_string() or (my personal favourite) by a Prepared Statement)
May 1 '09 #3
acoder
16,027 Expert Mod 8TB
Welcome to Bytes!

If that suggestion doesn't work, post your code.

PS. posts split off from other threads. Please post a new thread for posts rather than hijacking other members' threads. Thanks.
May 1 '09 #4
Hi,
How to do that ?
I tried this one but atill not work

Expand|Select|Wrap|Line Numbers
  1.     // $sql= sprintf("INSERT INTO tb_music VALUES ('$playlist_id','$playlist_name','$user_id','$song','$artist','$plass')",,
  2.                     mysql_real_escape_string($artist, $sql),
  3.                     mysql_real_escape_string($plass, $sql),
  4.                     mysql_real_escape_string($playlist_name, $sql),
  5.                     mysql_real_escape_string($playlist_id, $sql));
  6.  
  7. //
May 1 '09 #5
acoder
16,027 Expert Mod 8TB
That's not correct PHP. Have you had a look at the PHP manual? You mentioned that your code worked when not using Ajax. Are you sure about that?
May 1 '09 #6
oh yeah, i got it.
it's just one line to fix it and it is:
$artist = mysql_real_escape_string($_POST['artist']);

your answer is my angel you know ? if i don't have you maybe i have tp geot headach for more time. thanks so much.
May 3 '09 #7
acoder
16,027 Expert Mod 8TB
That looks more like it. Glad to see that you fixed it.
May 3 '09 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by David Cameron | last post: by
3 posts views Thread by Giggle Girl | last post: by
reply views Thread by thepisu | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.