Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "172.19.0.2";
- $username = "root";
- $password = "asdf";
- $dbname = "json_test";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $user_profile = array(
- 'firstname' => 'Mana',
- 'lastname' => 'Mungmana',
- 'ชื่อ' => 'มานะ',
- 'นามสกุล' => 'มุ่งมานะ'
- );
- $user_profile = json_encode($user_profile, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
- $sql = "INSERT INTO users (data)
- VALUES ('$user_profile')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Add Comment
Please, Sign In to add comment