Jump to content

using ' in mysql!!!


robcrozier

Recommended Posts

hi, im trying to input some text into a mysql text field using php.  Though everytime i use a ' in my text i get an error.  Here is the code that i'm using to insert the data into the table:

[code]
$query = "update stock
set title = '$t', description = '$d', price = '$p'
where id = '$i'";
[/code]

How can i tweak this to allow me to input inverted commas ( ' ) in the description and title fields?

Thanks!
Link to comment
Share on other sites

thanks mate thats done the trick!!!  ;D

However, i now have one more question:
  - Can you use a similar function to get mysql to accept commas and print them out when used in an INT field? At the min whenever i enter one, all of the data that follows it is not displayed.

thanks again!
Link to comment
Share on other sites

INT field is an integer 

1493 is an INT
1,493 is technically a string

You would have to format the output to display the comma for you.  Unless of course there is a particular function that I am unaware of to format numbers like that for you. I know there is one for formating decimals....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.