yshua Posted August 13, 2012 Share Posted August 13, 2012 Dear encouraging, appreciated people: All comments (even when my ears tingle) are taken positively. Am babystepping, taking my time, running PHP5.3.8, MYSQL5.5, Win7, Apache2.2 and receive following emsgs from a customer entry menu: Timestamp: 8/12/2012 6:32:24 PM Warning: A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. Source File: http://127.0.0.1/form.php Line: 0 Timestamp: 8/12/2012 6:32:24 PM Error: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol. Source File: http://127.0.0.1/insert.php Line: 0 Here is condensed code of php.insert: <?php include("admin/includes/db.php"); mysqli::__construct() ([ string $host = ini_get("mysqli.default_host") [, string $username = ini_get("mysqli.default_user") [, string $passwd = ini_get("mysqli.default_pw") [, string $dbname = "reccus2" [, int $port = ini_get("mysqli.default_port") [, string $socket = ini_get("mysqli.default_socket") ]]]]]] ) $mysqli = new mysqli('host', 'headache2', 'Mag114nes43ium44', 'reccus2'); /* * This is the "official" OO way to do it, * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0. */ if ($mysqli->connect_error) { die('Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error); } /* * Use this instead of $connect_error if you need to ensure * compatibility with PHP versions prior to 5.2.9 and 5.3.0. */ if (mysqli_connect_error()) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } echo 'Success... ' . $mysqli->host_info . "\n"; mysql_query("INSERT INTO users (fname,lname,address,city,state,zip,phone,emailid,howhear) VALUES ('".$_REQUEST['fname']."','".$_REQUEST['lname']."','".$_REQUEST['address']."','".$_REQUEST['city']."','".$_REQUEST['state']."','".$_REQUEST['zip']."','".$_REQUEST['ph_no']."' ,'".$_REQUEST['email']."','".$_REQUEST['howhear']."')"); session_start(); $_SESSION['user']=$_REQUEST['fname']; $mysqli->close(); if (mysql_error()) { echo "<br />". mysql_errno(). " : ". mysql_error(); } ?> Thanks, ahead of time, Yshua :-\ Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 13, 2012 Share Posted August 13, 2012 When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 13, 2012 Share Posted August 13, 2012 The problem is not related to that code at all, but rather the communication between your web server and browser. In short: Your browser is sending the content using the windows-1252 charset, while your web server (and code) expects UTF-8. The possible fixes for this has been listed in the first error message, with the most recommended one being to add the correct header to the HTTP header your browser sends. header ("content-type: text/html; charset=utf-8"); If that doesn't help, make sure your browser auto-selects the charset to use, and lastly the accept-charset attribute on the form element. Quote Link to comment Share on other sites More sharing options...
yshua Posted August 21, 2012 Author Share Posted August 21, 2012 Dear ChristianF: You nailed the problem! Am gaining momentum on solving it, but the handling of charset has gotten to a lot of other mysteries as well. Thanks for taking the time out. Have a great day, Yshua Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 21, 2012 Share Posted August 21, 2012 You're welcome, and I'm glad I could help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.