charset problem with wordpress
-
Hey,
I am creating a PHP file that will make changes to the wordpress database tables. For reasons that are explained in detail, I do not want to use the internal functions of WordPress to insert data into the database.In the PHP file, I save the data in the database, but in WordPress, it displays as a question mark.
$mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$mysqli->set_charset("utf8mb4");
$sql = "INSERT INTOwp_st_room_availability(post_id,check_in,check_out,number,post_type,adult_dbl_price,adult_price,child_price,child_nb_price,infant_price,extra_bed_price,status,priority,number_booked,parent_id,allow_full_day,number_end,booking_period,is_base,adult_number,child_number,room_price_modified,modified_by)
VALUES ('$_room_id', '$_stamp', '$_stamp', '$_room_stock', 'hotel_room', '$_room_dbl_c', '$_room_sgl_c', '$_room_chdwb_c', '$_room_chdnb_c', '$_room_infant_c', '$_room_tpl_c', '$_status', NULL, 0, '$_hotel_id', 'on', NULL, 0, 0, 1, 0, NOW(), '$_modifier_name')";
$result = $mysqli->query($sql);The data stored in the database through WordPress is also read as unintelligible characters when read by this PHP file.
نام کارگزار
Searching the internet, I found out that the problem is in the charset. In the wp-config.php file, the valuedefine( 'DB_CHARSET', 'latin1' );is set.
This WordPress site uses the Traveler theme, and I don’t know how to find out what charset it uses.I tried utf-8, utf8mb4 and latin1 in my PHP file, but the problem was not solved.
I will be grateful if you help me to find the problem and solve it.
The topic ‘charset problem with wordpress’ is closed to new replies.