Jump to content

Recommended Posts

Posted

έφτιαξα μία φόρμα στην όποια μέσω PHP καταχωρώ νέες εγγραφές σε μία βάση δεδομένων στην mysql

 

unledyi.png

 

αλλά όποτε καταχωρώ μέσω του site μια νέα εγγραφή με Ελληνικούς χαρακτήρες όπως βλέπετε στην mysql τους εμφανίζει με ερωτημάτικα αν και έχω αλλάξει την κωδικοποίηση στις PHP σελίδες σε UTF8 όπως έχω αλλάξει και την κωδικοποήση στην mysql σε UTF8

 

ξέρει κάνεις τι πρέπει να κάνω για να το διορθώσω?

Posted

Αν μπορείς δώσε μας τον κώδικα που που βάζεις κάθε καταχώρηση μέσα στην db.

Posted

ορίστε

 

<?php

 

$con=mysql_connect("localhost","developer","javalab");

if(!$con)

{

die('Δεν έγινε η σύνδεση με την βάση δεδομένων'.mysql_error());

}

 

mysql_select_db("cycladestravel", $con);

 

$sql="INSERT INTO travels(travel_id,travel_destination,travel_description,travel_price) VALUES

('$_POST[tID]','$_POST[tDestination]','$_POST[tDescription]','$_POST[tPrice]')";

mysql_set_charset('utf-8');

mysql_query("SET NAMES 'utf8';", $con);

mysql_query("SET CHARACTER SET 'UTF8';", $con);

if (!mysql_query($sql, $con))

{

die('Σφάλμα: ' . mysql_error());

}

 

echo " 1 εγγραφή καταχωρήθηκε ";

 

mysql_close($con)

?>

Posted

Δοκίμασε όπως φτιάχνεις το table να το ορίσεις κάπως έτσι:

 


CREATE TABLE IF NOT EXISTS `travels` (
  `travel_id` int(11) NOT NULL auto_increment,
  `travel_destination` varchar(255) collate utf8_unicode_ci NOT NULL,
  `travel_description` varchar(255) collate utf8_unicode_ci NOT NULL,
  `travel_price` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

 

Είναι πολύ βασικό επίσης να έχεις βάλει τα σωστά charsets και στις σελίδες που προβάλλονται τα records.

Posted

Δοκίμασε όπως φτιάχνεις το table να το ορίσεις κάπως έτσι:

 


CREATE TABLE IF NOT EXISTS `travels` (
  `travel_id` int(11) NOT NULL auto_increment,
  `travel_destination` varchar(255) collate utf8_unicode_ci NOT NULL,
  `travel_description` varchar(255) collate utf8_unicode_ci NOT NULL,
  `travel_price` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

 

Είναι πολύ βασικό επίσης να έχεις βάλει τα σωστά charsets και στις σελίδες που προβάλλονται τα records.

to dokimasa afto kai akoma to idio provlima iparxei kai epeisis oles i php selides exoun charset utf8

Posted

Μόνο στην db έχεις το πρόβλημα με το πως εμφανίζονται, ή και στην ιστοσελίδα που προβάλλεις τα records;

Posted

στην σέλιδα που προβάλω τα records εμφανίζονται κανονικά εκτός βέβαια αυτά τα οποία στην mysql εμφανίζονται με ??

Posted

στην σέλιδα που προβάλω τα records εμφανίζονται κανονικά εκτός βέβαια αυτά τα οποία στην mysql εμφανίζονται με ??

 

kita afou sta dixni stin selida mia xara logika kati pezei me to programa pou blepis tin db sou.

 

Posted

kita afou sta dixni stin selida mia xara logika kati pezei me to programa pou blepis tin db sou.

 

 

Αυτό ακριβώς. Άμα κάνεις τη δουλειά σου στην ιστοσελίδα, είσαι gg.

Posted

Αυτό ακριβώς. Άμα κάνεις τη δουλειά σου στην ιστοσελίδα, είσαι gg.

oxi den katalaves enow oses eggrafes exw kataxorisi me elinikous xaraktires stin db apo tin mysql tous emfanizei kanonika sto site alla an kanw kataxorisi apo to site me elinikous xaraktires tote kai stin mysql kai sto site tous emfanizei me erotimatika

Posted

μετα το connection με την database σου, βαλε

mysql_query("SET NAMES UTF8");

 

οταν κανεις POST data στο column travel_description,

απλα κανε escape το text μεσω του mysql_real_escape_string()

 

οταν το εμφανιζεις,

χρησιμοποιεισαι στο text για να διαβασει σε UTF-8

διαβασε περισσοτερο για to function αυτο στο php.net

$text = htmlentities($text, ENT_COMPAT, 'UTF-8');

 

πρεπει παντα να χρησιμοποεις UTF8(MySQL) και UTF-8(Browser) encoding.

επισης στο <head> tag βαλε

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

εαν εχεις και παλι προβλημα, reply.

Posted

evala to

mysql_query("SET NAMES UTF8");

 

kai to

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

alla den exw idea pou na valw to

$text = htmlentities($text, ENT_COMPAT, 'UTF-8');

 

kai pos na xrisimopoihso to  mysql_real_escape_string()

Posted

εφοσον εχεις μια φορμα που κανεις POST στην database σου, οταν πατησεις το button της φορμας σου και πριν βαλεις τα data μεσω του mysql_query("INSERT INTO ....");

 

οτιδηποτε μεταβλητη θα την περνας μεσω του

mysql_real_escape_string()

π.χ $text = mysql_real_escape_string($text); // εαν βαλω π.χ '1' or '' θα το κανει escape => \'1\' or \'\' ετσι ωστε να αποφυγεις το SQL injection

 

εαν θες να εμφανισεις κατι που ειναι se foreign characters, πρεπει να το τρεξεις μεσω του htmlentities($text, ENT_COMPAT, 'UTF-8') , ετσι ωστε να κανει encode ολους τους χαρακτηρες...

 

εαν παλι εχεις προβλημα, ποσταρε το μερος του κωδικα που χρησιμοποιεις για αυτη την λειτουργια

Posted

επείδη δεν βλέπω να βγάζω άκρη :)

 

 

<?php

 

$con=mysql_connect("localhost","developer","javalab");

mysql_query("SET NAMES UTF8");

if(!$con)

{

die('Δεν έγινε η σύνδεση με την βάση δεδομένων'.mysql_error());

}

 

mysql_select_db("cycladestravel", $con);

$sql="INSERT INTO travels(travel_id,travel_destination,travel_description,travel_price) VALUES

('$_POST[tID]','$_POST[tDestination]','$_POST[tDescription]','$_POST[tPrice]')";

mysql_set_charset('utf-8');

mysql_query("SET NAMES 'utf8';", $con);

mysql_query("SET CHARACTER SET 'UTF8';", $con);

if (!mysql_query($sql, $con))

{

die('Σφάλμα: ' . mysql_error());

}

 

echo " 1 εγγραφή καταχωρήθηκε ";

 

mysql_close($con)

?>

Posted

επείδη δεν βλέπω να βγάζω άκρη :)

 

 

<?php

 

$con=mysql_connect("localhost","developer","javalab");

mysql_query("SET NAMES UTF8");

if(!$con)

{

die('Δεν έγινε η σύνδεση με την βάση δεδομένων'.mysql_error());

}

 

mysql_select_db("cycladestravel", $con);

$sql="INSERT INTO travels(travel_id,travel_destination,travel_description,travel_price) VALUES

('$_POST[tID]','$_POST[tDestination]','$_POST[tDescription]','$_POST[tPrice]')";

mysql_set_charset('utf-8');

mysql_query("SET NAMES 'utf8';", $con);

mysql_query("SET CHARACTER SET 'UTF8';", $con);

if (!mysql_query($sql, $con))

{

die('Σφάλμα: ' . mysql_error());

}

 

echo " 1 εγγραφή καταχωρήθηκε ";

 

mysql_close($con)

?>

 

εφοσον δεν εμφανιζεις τιποτα αλλα κανεις post μονο, το htmlentities δεν το χρειαζεσαι.

 

Δοκιμασε τον παρακατω κωδικα:

<?php

 

$con=mysql_connect("localhost","developer","javalab");

mysql_query("SET NAMES UTF8");

if(!$con)

{

  die('Δεν έγινε η σύνδεση με την βάση δεδομένων'.mysql_error());

}

 

mysql_select_db("cycladestravel", $con);

$tID = $_POST["tID"];

$tDestination = $_POST["tDestination"];

$tDestination = mysql_real_escape_string($tDestination);

$tDescription = $_POST["tDescription"];

$tDescription = mysql_real_escape_string($tDescription);

$tPrice = $_POST["tPrice"];

$sql="INSERT INTO travels(travel_id,travel_destination,travel_description,travel_price) VALUES

('$tID','$tDestination','$tDescription','$tPrice')";

if (!mysql_query($sql, $con))

{

  die('Σφάλμα: ' . mysql_error());

}

 

echo " 1 εγγραφή καταχωρήθηκε ";

 

mysql_close($con)

?>

 

επεισης , δες αν η database σου ειναι utf8_unicode_ci οπως και ολα τα tables σου, τα columns που εχουν κειμενο

και οπως ειπα και να βαλεις και το meta tag

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

μετα το head tag.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Yeah, for sure. Hardly anyone doesn't use it yet, but those few are gonna give in soon. I'm not judging anyone who uses it – that's not the point. The point is that people do use it. I use it, you use it, we all use it. These days, it's just NORMAL. And it's gonna keep getting more and more normal. But like I said, you still gotta know what you're actually doing.
    • Then that's the problem. Server owners are as bad as they used to be in 2005, 2010 and so on.    This scene has technically mature developers, always money-hungry server owners, but what both these groups lack, is some creativity ... I would never play in a server that needs 7 layers of anti-bot. If it needs 7 layers of anti-bot, it means its a bot friendly server and not something worth playing. 
    • Lineage just has a giga boring quest line / lore and since server owners are not reinventing the wheel, players are forced to F1 F2 spam by server design.
    • Players say: We don't have time, please add auto-farm to the server, after all, farming in L2 is the most repetitive and boring thing, it gives no enjoyment.    Then players say: OMG your server is full of auto-farmers with adrenaline. Use anti-cheat guards.    Excluding the hilarious fact that an auto-farm player is essentiall botting without botting software ...   Noone stops to ask the simple question: If nobody likes farming to that extend that they go as far as building complex bots and ask for server-side bot programs and then for no apparent reason have to build anti-bot guards ... MAYBE the problem is that "farming" is an outdated feature that has to be removed from your servers ?   What you people are building here is software that protects a game feature, nobody likes and nobody wants to use.   Has the mental capacity of server owners and developers fallen so many IQ points the last decade ? One comes back to see the same server setups of a decade ago, with zero innovation, zero creativity and a huge amount of time and resources protecting a game feature nobody wants to even use ... The other dissappointing thing one sees here, is that a lot of GREAT developers who now work full time jobs in corporate, come back here, to bash the work of others because they find their current job tasks not as fullfilling as when they would develope game related code for Lineage 2...   Talking about life choices eh ? 😛
    • Have u seen the message i sent you?
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..