我有一个 JSON 字符串
{"name":"jack","school":"colorado state","city":"NJ","id":null}
我需要将它保存在数据库中。我该如何做到这一点?我的PHP代码已经连接到MySQL,但我无法保存记录。
<?php
// the MySQL Connection
mysql_connect("localhost", "username", "pwd") or die(mysql_error());
mysql_select_db("studentdatabase") or die(mysql_error());
// Insert statement
mysql_query("INSERT INTO student
(name, school,city) VALUES(------------------------- ) ") // (How to write this)
or die(mysql_error());
echo "Data Inserted or failed";
?>
jsonGiven
是什么。我的JSON字符串是这个{"name":"jack","school":"colorado state","city":"NJ","id":null}
。但我无法从我的PHP代码中读取它。 - Sharon Watinsan