douduan9129 2016-11-09 18:29
浏览 113

将带有空格的Unity3d字符串存储到MYSQL中的VARCHAR字段中

I'm working on something with Unity3d MySQL Db. I am passing values through $_GET PHP method but I'm having trouble with strings with white spaces when I store them into the assigned tables.

Let's say I have an InputField which gets the string I need. Then, I pass the string through the $_GET method, like this:

public InputField myInput;
public string a;

void StoreData()
{
     a = myInput.text;
     StartCoroutine(store(a));
}

IEnumerator store(string str)
{
     WWW connection = new WWW("http://localhost/route/store_company.php?name=" + str);
     yield return(connection);
}

So, after connecting to the DB, in the php file I have:

$name = $_GET['name'];
$query = "INSERT INTO company(id, name) VALUES (NULL, '$name')";
$get_query = mysqli_query($connection, $query);
echo '101';

If I type "Example" in the InputField, the VARCHAR column called name will have "Example". But if I type "This is an example", the VARCHAR column just stores the first word ("This") missing the rest of the sentence.

I've sat the VARCHAR to 70 (Length). Pretty new using MySQL. ¿How I capture the whole sentence and why don't work if I am passing a string variable?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题