Save mysql php array

I am trying to store an array of values ​​in a MySQL database. Here is my code:

$values = array('jaime','11124583363', '5554625', '312458795','1999-12-02','soldierjesus', 'calle 12', 'carismatica', 'necesito oracion', '1', '1'); $data->create_persons('new_person', $values); public function create_persons($table, $values) { $query = ("INSERT INTO $table ('name', 'number_document','phone', 'cell_phone', 'birth_date', 'email', 'address', 'other_church', 'pray_request', 'districts_id', 'professions_id') VALUES('".implode("','", $values).")'") or die(mysqli_error()); mysqli_query($this->_connection, $query); } 

Numbers Can't β†’ ''
How to do it?

thanks

0
source share
2 answers

change

 VALUES('".implode("','", $values).")'") 

in

 VALUES('".implode("','", $values)."')") 

In other words, change ")'" to "')"

+4
source

I didn't take much time, but I think the insert request is inserted here:

 `$query = ("INSERT INTO $table ('name', 'number_document','phone', 'cell_phone', 'birth_date', 'email', 'address', 'other_church', 'pray_request', 'districts_id', 'professions_id') VALUES('".implode("','", $values)."')") or die(mysqli_error());` 

"(single quote) to close VALUES () was in the wrong place.

Regards, Charlie

0
source

Source: https://habr.com/ru/post/904793/


All Articles