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 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大