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
https://forums.phpfreaks.com/topic/18423-using-in-mysql/
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
https://forums.phpfreaks.com/topic/18423-using-in-mysql/#findComment-79239
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
https://forums.phpfreaks.com/topic/18423-using-in-mysql/#findComment-79245
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.