Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

accent problem jquery.sqlbuilderdemo-0.06.js

Posted on 2010-09-20
28
Medium Priority
?
757 Views
Last Modified: 2012-05-10
Hi,

I'm using this plugin sqlbuilderdemo-0.06.js
http://plugins.jquery.com/project/SQL_QUERY_BUILDER
and when displaying data from the database all accent become a question mark
(ISO 8859-1 (Latin-1) Characters List - for french)
I'm looking for a way to fix it.

Thanks
0
Comment
Question by:lenamtl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 14
  • 14
28 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 33738295
and you are using the same encoding everywhere (database, code and html) ?
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33743160
Yes, all other page display correctly, the DB is set to latin1

This is only when using this javascript that contain some ajax that does not display special characters correctly. I can't change the entire site and db to UTF-8.
application and that was fixing the problem

<?php
   mb_convert_encoding("té trö lôl uè mdr!!!1", "UTF-8", "ISO-8859-1");
 ?>

or

<?php
echo iconv("ISO-8859-1","UTF-8","té trö lôl uè mdr!!!1");
?>


But using this javascript sqlbuilderdemo I don't know where to put this piece of code...to make it work.
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33743259
If you want to test you can get the package
http://plugins.jquery.com/node/9163/release
you will need to download version 0.06 and 0.05 cause query.php is missing in the 0.06 version.

I want to use it in my custom PHP/MySQL web application.

Thanks
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 82

Expert Comment

by:leakim971
ID: 33743711
Je ne pense pas que tu puisses utiliser mb_convert_encoding et iconv parce que le code PHP reçoit la requête toute faite.

You can try to edit query.php line 5 :

We replace :
$querytorun=stripslashes($_POST['querytorun']);

By:
$querytorun = stripslashes( mb_convert_encoding( $_POST['querytorun'] ), "UTF-8", "ISO-8859-1");
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33746637
Hi,

Ok I have try your solution and I'm getting these errors
Warning: Wrong parameter count for mb_convert_encoding()
Warning: Wrong parameter count for stripslashes()
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33746930
Better :


$querytorun = stripslashes( mb_convert_encoding( $_POST['querytorun'] , "UTF-8", "ISO-8859-1") );

Open in new window

0
 
LVL 26

Author Comment

by:lenamtl
ID: 33752863
This time no error but still accent problem :(
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33806743
Still need a solution for this any clues?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33807965
Did you try a simple ajax call to return some data the simple way from the database to check if your get the question marks too?
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33808798
Sorry my ajax knowledge is very limited..
If I check in the DB or display DB table using PHP the record are displayed correcty
for example for the word "Hôpital" if I check in the DB or in PHP request I can see "Hôpital"

When displaying  "Hôpital" using this jquery plugin it's displaying  "H?pital"



0
 
LVL 82

Expert Comment

by:leakim971
ID: 33808887
No worries,

create a php page getting data from the database and return it for example the field having : "Hôpital"


<?PHP

// stuff to connect to database
$sql = "SELECT myField FROM myTable WHERE ID = someIDWillReturnHopital";
// run the query
// get the field

print $hopital; // should print hôpital (from the database)

?>

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33808948
and check with a simple ajax call :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript"> 
	$(document).ready(function() {
		$.get("mySimplePHPScript.php", function(data) {
			$("input").val( data );
		});
	});
</script> 
<body> 
<input  />
</body> 
</html>

Open in new window

0
 
LVL 26

Author Comment

by:lenamtl
ID: 33808959
I'm confused...

You code looks like a basic php request...
It is not ajax call?

0
 
LVL 26

Author Comment

by:lenamtl
ID: 33808973
oups ok you have posted the second part :)
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33808998
this is for testing purpose, to be sure we get valid char from database with a simple ajax call before using the plugin

we have two page/code :

a php script return the field from the database (you should select a row and a field with "hôpital")

a html, client side page calling the previous script and put the result ("hôpital" or "h?pital") in a textbox
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33809003
>oups ok you have posted the second part :)

;-))
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33809301
Ok I will test that, I will need to set $hopital variable to make it work.

I'm going to lunch and II will be back in one hour
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33809442
>Ok I will test that, I will need to set $hopital variable to make it work.

yes from the database,
ok, see you later
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33810195
I got this
 H¿al
for
Hôpital


0
 
LVL 82

Expert Comment

by:leakim971
ID: 33810309
change simple ajax call page to :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>Untitled Document</title> 
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript"> 
	$(document).ready(function() {
		$.get("mySimplePHPScript.php", function(data) {
			$("input").val( data );
		});
	});
</script> 
<body> 
<input  />
</body> 
</html>

Open in new window

0
 
LVL 26

Author Comment

by:lenamtl
ID: 33810468
same result

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33810902
could you confirm collation for the database table latin1_general_ci ? I was assuming the charset is latin1.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33811189
Put this in you php script :

header("Content-Type: text/plain; charset=ISO-8859-1");

It work for me :
<?PHP
    $link = mysql_connect("localhost", "root", "password");
    mysql_select_db("database", $link);
    
    $sql = "SELECT * FROM latinos";
    $result = mysql_query($sql);
 
    if($row = mysql_fetch_array($result)) {
        $hopital = $row[0];
    }
   
    header("Content-Type: text/plain; charset=ISO-8859-1");
    print $hopital;

?>

Open in new window

hopital.jpg
0
 
LVL 26

Author Comment

by:lenamtl
ID: 33814204
Ok your example finally work.
Now to make this work with the script where should I place the
wherw should I add
header("Content-Type: text/plain; charset=ISO-8859-1");

and what else should I do with these files
reports.php (my report page)
query.php
reportshandler.php
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 33814341
>where should I add : header("Content-Type: text/plain; charset=ISO-8859-1");

Good to put it before any command sending data out in the query.php file.
I see only echo and die so why not on the first line ? (second
<?

header("Content-Type: text/plain; charset=ISO-8859-1");

/*this query takes sql clause taht sends an html table back with the data..*/

$querytorun=stripslashes($_POST['querytorun']);

Open in new window

0
 
LVL 26

Author Comment

by:lenamtl
ID: 33814400
Ok fantastic it's work ok now!
Thanks you so much!
0
 
LVL 26

Author Closing Comment

by:lenamtl
ID: 33814403
Thanks for your patience!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33814404
You're very welcome! Thanks for the points! Have a nice week-end!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question