My table in postgresql is truncating these strings
I have a table in VMobjects like this
MGRCONFIG_DB=# select * from vmobjects;
guid | ipaddress | username | password | hostid | vmname | guestostype | guestos
name
-----------------------------------+---------------+----------+----------+----------+-----------------+-------------+--------
-----
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 | @@@@@@@@@@@@@@ | 开发者_StackOverflowwindows |
9126180214dcd367a5b42e0.23605256 | fsdfdsfdsf | | | Physical | fdsaj;( | windows |
11086632854dcd36f62f7e79.14470771 | dfsdfsd | | | Physical | ^ | windows |
Now I have a php page addvm.php
, when I add username/ip/password/
or anything it gets truncated
gets truncated on entering data as '~!@#$%^&*()_+=-`{}|\][:"';<>?/.,' for all fields.
After using pg_escape_string i am able to insert '~!@#$%^()_=-`{}|][:"';<>?/. all strings except + and &. @Emil Vikström: say that i have to use urlencode for this. but i don't no, How & whr it is used?
Use pg_escape_string on the data before entering it into your SQL query:
$data = '~!@#$%^&*()_+=-';
$data_escaped = pg_escape_string($data);
$query = 'INSERT INTO table (data) VALUES("'. $data_escaped .'");';
精彩评论