Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7419949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:09:26+00:00 2026-05-29T08:09:26+00:00

I’m new to PHP, HTML and MySQL, and have encountered the following problem: I

  • 0

I’m new to PHP, HTML and MySQL, and have encountered the following problem:

I have a PHP document which outputs the results of a MySQL query. Because the MySQL database and thus the output results have some non-standard characters (such as æ or á), my PHP document and the MySQL database/tables are encoded as utf-8.
For instance, here is an example of the a database entry and correct output:
goahteæjgáda

When the PHP document does not have anything in the HTML <head/> node (not even comments), then the search is successful and the output is displayed correctly (but then I can’t apply my external css or include the shortcut icon, etc.).

However, if there is anything at all in the HTML <head/> node, such as standard metadata concerning content type, links to css and icon files, keywords, or even just <!-- comments -->, then either:

  1. the search does not work if the string being searched for contains a non-standard character
    OR
  2. any non-standard characters in the resulting output are displayed as � — for instance, the example above shows up like this after searching for “goahte”:
    goahte�jg�da

Any help would be appreciated!

Here is my code:

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link href='style_mavsulasj.css' rel='stylesheet' type='text/css'/>
  <link rel='shortcut icon' href='farben4.gif'/>
  <title>search</title>
</head>
<body>

<div style="width:230px;padding:0px;margin:0px;float:left;">
<table border="0">
<tr><td>Search here:</td><td>
<?php if (strlen($_GET['smj'])==0) echo ""; else echo "current search"; ?>
</td></tr>
<form action="" method="GET">
<tr><td colspan="2">Entry:</td></tr>
<tr><td><input type='text' name='smj' value=''></input></td><td align='center'><?php echo "<span class='searchCrits' > ".$_GET['smj']."</span>"; ?></td></tr>
<tr><td colspan="2"><input type="submit" value="submit query"/></td></tr>
</form>
</table>
</div>

<div style="width:960px;padding:30px;margin-left:210px;">
<?php
if($_GET){
$smj = $_GET['smj'];
$connect = mysql_connect("localhost","root","root");
    if($connect){    
        $toDB = mysql_select_db("bigG_reimport_test",$connect);
        if($toDB){
            $query = "SELECT * FROM reimport_Sheet1 WHERE smj LIKE '" . $smj . "%'";
            $results = mysql_query($query);
            echo "<span class='header4'>results:<br/>";
            while($row = mysql_fetch_array($results)){
                echo "-> " . $row['smj'] . "<br/>" ;
                }
            echo "</span><br/>";
            } 
        else {die("Failed to connect to database!<br/>" . mysql_error());}}
        else {die("Failed to connect to mysql!<br/>" . mysql_error());}}
?>
</div>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:09:27+00:00Added an answer on May 29, 2026 at 8:09 am

    Make sure:

    1. Your PHP source file is encoded as UTF-8 (yes, this really matters, sadly)
    2. You’ve set the charset in your MySQL session to UTF-8. See mysql_set_charset
    3. You set the encoding to UTF-8 in your HTTP headers.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.