在php中传递文本并获取.0。 在sql中

I built a system - website, I try to pass text in php and get it in the sql. the text need to be name of category for example "Food".

now this is the code I have:

if(isset($_GET['data'])){
$data = $_GET['data'];
$data = preg_replace('/\\\"(.*?)\\\"/', '"$1"', $data);
$data = json_decode($data);
    $category = 'text1';
    $amount = $data[2];
    $repeated = $data[3];
    $note = $data[4];

    echo $category;
    echo $amount;
    echo $repeated;
    echo $note;

$query = mysql_query("INSERT INTO `Expenses` (Accountid, Category, Amount, Repeated) VALUES ('.$accountid.' '.$category.', '.$amount.', '.$repeated.', '.$note.')");}

I'm not sure but I think the problem is in the sql column type, I tried to pass hard coded string 'text1' and its show me in the sql .0. and I don’t know why... I tried to put the column in the sql as type "TEXT" and even "VARCHAR", collection: UTF8_GENERAL_CI and even ASCII_GENERAL_CI but its not help, the text look like .0.

when I see what is print in the php page its look good I mean I see the word Food..

I use PHP MY ADMIN.

There might be more than one bug, but you're missing a comma in this line

$query = mysql_query("INSERT INTO `Expenses` (Accountid, Category, Amount, Repeated) VALUES ('.$accountid.' '.$category.', '.$amount.', '.$repeated.', '.$note.')");}

See '.$accountid. ' '.$category.' Should be '.$accountid. ', '.$category.'

Also note, that you can instead just do '$accountid', '$category' .

Why are you using . in your query? try this:

$query = mysql_query("INSERT INTOExpenses(Accountid, Category, Amount, Repeated) VALUES ('$accountid', '$category', '$amount', '$repeated', '$note')");

Dots . are used for concatenation which you don't need in your case.