How to search values from database using ā, è
up vote
0
down vote
favorite
I want search ā, è.. this special characters and show in page, but when i search the value its converting into different characters. am getting 'nor result found
my html:
<form action="" method="GET">
<input type="text" name="name" id="name">
<input type="submit" name="submit">
</form>
this is my php code
<?php
$conn = mysqli_connect("localhost","root","","test2");
// Check connection
if (mysqli_connect_errno())
echo "Failed to connect
to MySQL: " . mysqli_connect_error();
if(isset($_GET['submit']))
$ksl = $_GET['name'];
$sql = "SELECT * FROM app WHERE texts LIKE '%$ksl%' ";
if($result = mysqli_query($conn, $sql))
if(mysqli_num_rows($result) > 0)
while($row = mysqli_fetch_array($result))
echo $row['texts'];
else
echo "No records matching your query were found.";
else
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
// Close connection
mysqli_close($conn);
?>
my js code
<script type="text/javascript">
$(document).ready(function()
$('#name').keyup(function()
var gk = $(this).val();
$.ajax(
type: 'GET',
url: 'test.php',
data:
'submit': true,
'name' : gk,
,
success: function (data)
$('#testa').html(data);
);
)
);
</script>
how to use special characters in search?
javascript php mysqli
add a comment |
up vote
0
down vote
favorite
I want search ā, è.. this special characters and show in page, but when i search the value its converting into different characters. am getting 'nor result found
my html:
<form action="" method="GET">
<input type="text" name="name" id="name">
<input type="submit" name="submit">
</form>
this is my php code
<?php
$conn = mysqli_connect("localhost","root","","test2");
// Check connection
if (mysqli_connect_errno())
echo "Failed to connect
to MySQL: " . mysqli_connect_error();
if(isset($_GET['submit']))
$ksl = $_GET['name'];
$sql = "SELECT * FROM app WHERE texts LIKE '%$ksl%' ";
if($result = mysqli_query($conn, $sql))
if(mysqli_num_rows($result) > 0)
while($row = mysqli_fetch_array($result))
echo $row['texts'];
else
echo "No records matching your query were found.";
else
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
// Close connection
mysqli_close($conn);
?>
my js code
<script type="text/javascript">
$(document).ready(function()
$('#name').keyup(function()
var gk = $(this).val();
$.ajax(
type: 'GET',
url: 'test.php',
data:
'submit': true,
'name' : gk,
,
success: function (data)
$('#testa').html(data);
);
)
);
</script>
how to use special characters in search?
javascript php mysqli
Probably a Dup of stackoverflow.com/questions/279170/utf-8-all-the-way-through
– RiggsFolly
Aug 13 at 18:16
Possible duplicate of How can I find non-ASCII characters in MySQL?
– Isaac
Aug 13 at 18:23
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want search ā, è.. this special characters and show in page, but when i search the value its converting into different characters. am getting 'nor result found
my html:
<form action="" method="GET">
<input type="text" name="name" id="name">
<input type="submit" name="submit">
</form>
this is my php code
<?php
$conn = mysqli_connect("localhost","root","","test2");
// Check connection
if (mysqli_connect_errno())
echo "Failed to connect
to MySQL: " . mysqli_connect_error();
if(isset($_GET['submit']))
$ksl = $_GET['name'];
$sql = "SELECT * FROM app WHERE texts LIKE '%$ksl%' ";
if($result = mysqli_query($conn, $sql))
if(mysqli_num_rows($result) > 0)
while($row = mysqli_fetch_array($result))
echo $row['texts'];
else
echo "No records matching your query were found.";
else
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
// Close connection
mysqli_close($conn);
?>
my js code
<script type="text/javascript">
$(document).ready(function()
$('#name').keyup(function()
var gk = $(this).val();
$.ajax(
type: 'GET',
url: 'test.php',
data:
'submit': true,
'name' : gk,
,
success: function (data)
$('#testa').html(data);
);
)
);
</script>
how to use special characters in search?
javascript php mysqli
I want search ā, è.. this special characters and show in page, but when i search the value its converting into different characters. am getting 'nor result found
my html:
<form action="" method="GET">
<input type="text" name="name" id="name">
<input type="submit" name="submit">
</form>
this is my php code
<?php
$conn = mysqli_connect("localhost","root","","test2");
// Check connection
if (mysqli_connect_errno())
echo "Failed to connect
to MySQL: " . mysqli_connect_error();
if(isset($_GET['submit']))
$ksl = $_GET['name'];
$sql = "SELECT * FROM app WHERE texts LIKE '%$ksl%' ";
if($result = mysqli_query($conn, $sql))
if(mysqli_num_rows($result) > 0)
while($row = mysqli_fetch_array($result))
echo $row['texts'];
else
echo "No records matching your query were found.";
else
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
// Close connection
mysqli_close($conn);
?>
my js code
<script type="text/javascript">
$(document).ready(function()
$('#name').keyup(function()
var gk = $(this).val();
$.ajax(
type: 'GET',
url: 'test.php',
data:
'submit': true,
'name' : gk,
,
success: function (data)
$('#testa').html(data);
);
)
);
</script>
how to use special characters in search?
javascript php mysqli
javascript php mysqli
edited Nov 11 at 3:10
Cœur
17.3k9102142
17.3k9102142
asked Aug 13 at 18:05
maffidesigners
307
307
Probably a Dup of stackoverflow.com/questions/279170/utf-8-all-the-way-through
– RiggsFolly
Aug 13 at 18:16
Possible duplicate of How can I find non-ASCII characters in MySQL?
– Isaac
Aug 13 at 18:23
add a comment |
Probably a Dup of stackoverflow.com/questions/279170/utf-8-all-the-way-through
– RiggsFolly
Aug 13 at 18:16
Possible duplicate of How can I find non-ASCII characters in MySQL?
– Isaac
Aug 13 at 18:23
Probably a Dup of stackoverflow.com/questions/279170/utf-8-all-the-way-through
– RiggsFolly
Aug 13 at 18:16
Probably a Dup of stackoverflow.com/questions/279170/utf-8-all-the-way-through
– RiggsFolly
Aug 13 at 18:16
Possible duplicate of How can I find non-ASCII characters in MySQL?
– Isaac
Aug 13 at 18:23
Possible duplicate of How can I find non-ASCII characters in MySQL?
– Isaac
Aug 13 at 18:23
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
As far as I'm aware you can't do this in mysql. Some workarounds of this use HEX values instead to search for these accents, a work around that I have used ages ago, which is not an ideal way but it did work is to do something like this
SELECT * FROM `app` WHERE `text` REGEXP '(s|š|Š|[sšŠ])(i|í|Í|[iíÍ])(r|ŕ|Ŕ|
. ř|Ř|[rŕŔřŘ])(e|é|É|ě|Ě|[eéÉěĚ])(n|ň|Ň|[nňŇ])(A|a|á|Á|ä|Ä|0|[AaáÁäÄ0])'
Or from doing some more research I found a way to use something like this
SELECT whateverYouWant
FROM app
WHERE text <> CONVERT(columnToCheck USING ASCII)
The CONVERT(col USING charset) function will turns the unconvertable characters into replacement characters. Then, the converted and unconverted text will be unequal.
Take a look at this link to find more information about this: https://dev.mysql.com/doc/refman/5.7/en/charset-repertoire.html
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
I haven't tried this personally but I imagine you'd be able tobind_value()and then use that in the statement. Unsure about how well documented that is though
– Isaac
Aug 13 at 18:50
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51828164%2fhow-to-search-values-from-database-using-%25c4%2581-%25c3%25a8%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
As far as I'm aware you can't do this in mysql. Some workarounds of this use HEX values instead to search for these accents, a work around that I have used ages ago, which is not an ideal way but it did work is to do something like this
SELECT * FROM `app` WHERE `text` REGEXP '(s|š|Š|[sšŠ])(i|í|Í|[iíÍ])(r|ŕ|Ŕ|
. ř|Ř|[rŕŔřŘ])(e|é|É|ě|Ě|[eéÉěĚ])(n|ň|Ň|[nňŇ])(A|a|á|Á|ä|Ä|0|[AaáÁäÄ0])'
Or from doing some more research I found a way to use something like this
SELECT whateverYouWant
FROM app
WHERE text <> CONVERT(columnToCheck USING ASCII)
The CONVERT(col USING charset) function will turns the unconvertable characters into replacement characters. Then, the converted and unconverted text will be unequal.
Take a look at this link to find more information about this: https://dev.mysql.com/doc/refman/5.7/en/charset-repertoire.html
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
I haven't tried this personally but I imagine you'd be able tobind_value()and then use that in the statement. Unsure about how well documented that is though
– Isaac
Aug 13 at 18:50
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
|
show 2 more comments
up vote
0
down vote
As far as I'm aware you can't do this in mysql. Some workarounds of this use HEX values instead to search for these accents, a work around that I have used ages ago, which is not an ideal way but it did work is to do something like this
SELECT * FROM `app` WHERE `text` REGEXP '(s|š|Š|[sšŠ])(i|í|Í|[iíÍ])(r|ŕ|Ŕ|
. ř|Ř|[rŕŔřŘ])(e|é|É|ě|Ě|[eéÉěĚ])(n|ň|Ň|[nňŇ])(A|a|á|Á|ä|Ä|0|[AaáÁäÄ0])'
Or from doing some more research I found a way to use something like this
SELECT whateverYouWant
FROM app
WHERE text <> CONVERT(columnToCheck USING ASCII)
The CONVERT(col USING charset) function will turns the unconvertable characters into replacement characters. Then, the converted and unconverted text will be unequal.
Take a look at this link to find more information about this: https://dev.mysql.com/doc/refman/5.7/en/charset-repertoire.html
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
I haven't tried this personally but I imagine you'd be able tobind_value()and then use that in the statement. Unsure about how well documented that is though
– Isaac
Aug 13 at 18:50
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
|
show 2 more comments
up vote
0
down vote
up vote
0
down vote
As far as I'm aware you can't do this in mysql. Some workarounds of this use HEX values instead to search for these accents, a work around that I have used ages ago, which is not an ideal way but it did work is to do something like this
SELECT * FROM `app` WHERE `text` REGEXP '(s|š|Š|[sšŠ])(i|í|Í|[iíÍ])(r|ŕ|Ŕ|
. ř|Ř|[rŕŔřŘ])(e|é|É|ě|Ě|[eéÉěĚ])(n|ň|Ň|[nňŇ])(A|a|á|Á|ä|Ä|0|[AaáÁäÄ0])'
Or from doing some more research I found a way to use something like this
SELECT whateverYouWant
FROM app
WHERE text <> CONVERT(columnToCheck USING ASCII)
The CONVERT(col USING charset) function will turns the unconvertable characters into replacement characters. Then, the converted and unconverted text will be unequal.
Take a look at this link to find more information about this: https://dev.mysql.com/doc/refman/5.7/en/charset-repertoire.html
As far as I'm aware you can't do this in mysql. Some workarounds of this use HEX values instead to search for these accents, a work around that I have used ages ago, which is not an ideal way but it did work is to do something like this
SELECT * FROM `app` WHERE `text` REGEXP '(s|š|Š|[sšŠ])(i|í|Í|[iíÍ])(r|ŕ|Ŕ|
. ř|Ř|[rŕŔřŘ])(e|é|É|ě|Ě|[eéÉěĚ])(n|ň|Ň|[nňŇ])(A|a|á|Á|ä|Ä|0|[AaáÁäÄ0])'
Or from doing some more research I found a way to use something like this
SELECT whateverYouWant
FROM app
WHERE text <> CONVERT(columnToCheck USING ASCII)
The CONVERT(col USING charset) function will turns the unconvertable characters into replacement characters. Then, the converted and unconverted text will be unequal.
Take a look at this link to find more information about this: https://dev.mysql.com/doc/refman/5.7/en/charset-repertoire.html
answered Aug 13 at 18:21
Isaac
522216
522216
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
I haven't tried this personally but I imagine you'd be able tobind_value()and then use that in the statement. Unsure about how well documented that is though
– Isaac
Aug 13 at 18:50
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
|
show 2 more comments
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
I haven't tried this personally but I imagine you'd be able tobind_value()and then use that in the statement. Unsure about how well documented that is though
– Isaac
Aug 13 at 18:50
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
its working, but how to use " where text like '%$thepostvalue%" in this section "SELECT whateverYouWant FROM app WHERE text <> CONVERT(columnToCheck USING ASCII)"
– maffidesigners
Aug 13 at 18:45
I haven't tried this personally but I imagine you'd be able to
bind_value() and then use that in the statement. Unsure about how well documented that is though– Isaac
Aug 13 at 18:50
I haven't tried this personally but I imagine you'd be able to
bind_value() and then use that in the statement. Unsure about how well documented that is though– Isaac
Aug 13 at 18:50
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
@maffidesigners was my answer helpful?
– Isaac
Aug 14 at 10:42
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
actually, it's working, but the problem with bind the value (''when I search particular charset value not working "). am trying with given reference. thank you
– maffidesigners
Aug 14 at 11:18
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
No problem, keep me posted and if it works accept the answer, if not don't so other people can give it a go!
– Isaac
Aug 14 at 11:19
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51828164%2fhow-to-search-values-from-database-using-%25c4%2581-%25c3%25a8%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Probably a Dup of stackoverflow.com/questions/279170/utf-8-all-the-way-through
– RiggsFolly
Aug 13 at 18:16
Possible duplicate of How can I find non-ASCII characters in MySQL?
– Isaac
Aug 13 at 18:23