Home  >  Article  >  Backend Development  >  mysql字段插入代码解决思路

mysql字段插入代码解决思路

WBOY
WBOYOriginal
2016-06-13 12:15:40759browse

mysql字段插入代码
想在数据库的body字段中插入一句完整的代码:

array (29 => '1',)
php应该怎么写?
------解决思路----------------------
<br />$arr = array (29 => '1');<br />$sqlstr = "insert into table(body) values('".json_encode($arr)."')";<br />mysql_query($sqlstr) or die(mysql_error());<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn