Hello, How can I store, get, and set strings in MySQL? I tried this in my create table if not exists thing: Code: tag VARCHAR(16) DEFAULT "Guest" In the database it saves the tag column as a varchar with the value "0". It stays 0 even if I run: PHP: $getName = "Andrey"; $this->db->query("UPDATE players SET tag=Owner WHERE name = '".strtolower($this->db->escape_string($getName))."'"); Any help? Thanks
Try this: PHP: $getName = "Andrey"; $this->db->query("UPDATE players SET tag = 'Owner' WHERE name = '".strtolower($this->db->escape_string($getName))."'");
Or that Code: $getName = "Andrey"; $this->db->query("UPDATE players SET tag=Owner WHERE name = 'strtolower($getName)'");
I recommend PHP: $name = " Andrey";$this->db->query("UPDATE players SET tag='Owner' WHERE name='{$this->db->escape_string(strtolower($name))}'"); BTW, MySQL by default is case-insensitive for = checks.
tag=Owner On SQL you need to tag='Owner' And strtolower will become part of the query passed to MySQL server instead of being run by PHP.
Why ecape string ? "Andrey" -> strtolower -> "andrey". So just "andrey" work in mysql x) i use this so much time when i code in PHP and it work perfectly .
PHP: "strtolower('abc')" and PHP: "'" . strtolower("abc") . "'" Are different. MySQL doesn't have a function called strtolower; only PHP does.