John Davidson

php - What's the best collation to use in MySQL for it to include spaces?

0 comments
Message:


So, I have this project, where a user can update a field, which works as intended.


The issues start when the user enters a space ' ' in the field.


For example, let's say the field was originally test1, and user changes it to test 1. This change takes place, and is printed as intended as well.


However, if the user goes ahead and inputs anything, from test1 to test1 to whatever, the change doesn't take place at all. No matter what the user inputted.


I'm sensing it has something to do with the collation I use in the database, and no matter which one I used, the issue is still present, and, to be frank, I don't know much about collations to begin with.


The code that updates the field is simply:


   `$query = $pdo -> prepare("SELECT 1 FROM table WHERE field = ?");
$query -> bindValue(1, $new_name);

$query -> execute();
$num = $query -> rowCount();

if ($num == 0) {

$query = $pdo -> prepare("UPDATE table SET table = ? WHERE table = ?");
$query -> bindValue(1, $new_name);
$query -> bindValue(2, $old_name);

$query -> execute();
}`

Does someone have have any input on my problem, either as to how's caused or how to fix it?


Thank you in advance



My Answer:
is PHP?

PHP is a server-side scripting language that is used to develop dynamic web applications and websites. It stands for Hypertext Preprocessor and is widely used for creating interactive and dynamic web pages. PHP code is embedded within HTML code and is executed on the server before the resulting HTML is sent to the client's web browser. It is a popular choice for web development due to its ease of use, flexibility, and compatibility with various databases and web servers.

Rate this post

3 of 5 based on 5546 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us