Dear All
For my new site, up until this point I have been using a MySQL database package to set up initial tables and insert test data, whilst developing the database 'reading' parts of the site.
However, I have now come across a problem - whilst I am able to use the MySQL syntax perfectly well, I am unable to insert text into the TEXT fields on the database table I am trying to write to, because it contains a comma and thus MySQL thinks that I am delimiting the fields rather than using English punctuation.
The 'comma' comes from text typed into a text area by the user, which I consequently want to write to the database.
Your help would be very much appreciated.
Many thanks
Mark
INSERTing text containing commas into MySQL database
Moderator: General Moderators
This is a generic form:
Regards
Mark
Code: Select all
$query = 'INSERT INTO Datatable1 VALUES ('.$myid.', '.$_SESSION['Int_value1'].', '.$_SESSION['Int_value2'].', '.$_SESSION['text1'].', '.$_SESSION['text2'].', '.$_SESSION['float1'].', '.$_SESSION['text3'].', '.$_SESSION['text4'].', '.$_SESSION['int_value3'].', '.$_SESSION['int_value4'].', '.$_SESSION['int_value5'].')';Mark
Yeah, you're not quoting the values. Try :
Code: Select all
$query = "INSERT INTO Datatable1 VALUES (
'$propid',
'{$_SESSION['Int_value1']}',
'{$_SESSION['Int_value2']}',
'{$_SESSION['text1']}',
'{$_SESSION['text2']}',
'{$_SESSION['float1']}',
'{$_SESSION['text3']}',
'{$_SESSION['text4']}',
'{$_SESSION['int_value3']}',
'{$_SESSION['int_value4']}',
'{$_SESSION['int_value5']}')";