我在VMobjects中有一个这样的表MGRCONFIG_DB=# select * from vmobjects; guid | ipaddress | username | password | hostid | vmname | guestostype | guestosname-----------------------------------+---------------+----------+----------+----------+-----------------+-------------+------------- 7728235734dcd25700e7c02.96324791 | gsdag | gsdasd | | Physical | rag | windows | 3642656604dcd343d3bcd11.54875889 | fsd | | | Physical | derde | windows | 17714467484dcd35dd0fa677.27764184 | dsf | | | Physical | fdsfd | windows | 1837080764dcd362fafe404.83675706 | fgf | | | Physical | fgf | windows | 2791118544dcd363df11bf1.21924610 | fdghhg | | | Physical | $%^ | windows | 7716352574dcd365c9eb777.30236042 | dsffd | | | Physical | ^ | windows | 10753160514dcd366631f5b6.48505657 | gfdgd | | | Physical | @ | windows | 8253046164dcd366f177bc3.85542378 | ghgfdhg | | | Physical | @@@@@@@@@@@@@@ | windows | 9126180214dcd367a5b42e0.23605256 | fsdfdsfdsf | | | Physical | fdsaj;( | windows | 11086632854dcd36f62f7e79.14470771 | dfsdfsd | | | Physical | ^ | windows |现在我有一个php页面addvm.php,当我添加username/ip/password/或任何内容时,它会被截断gets truncated on entering data as '~!@#$%^&*()_+=-`{}|\][:"';<>?/.,' for all fields.使用pg_escape_string我可以插入'~!@#$%^()_=-`{}|][:"';?/. 所有字符串,除了+和&。@埃米尔·维克斯特伦:假设我必须使用urlencode。但我不知道,怎么用,怎么用? (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 在将数据输入SQL查询之前,请对其使用pg_escape_string:$data = '~!@#$%^&*()_+=-';$data_escaped = pg_escape_string($data);$query = 'INSERT INTO table (data) VALUES("'. $data_escaped .'");';关于php - 我在PostgreSQL中的表正在截断这些字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5989418/ (adsbygoogle = window.adsbygoogle || []).push({}); 10-09 23:53