简体   繁体   中英

select one column value in mysql

I am facing problem to select data from database in mysql.

my table name is:
record 在此处输入图片说明

my query is:

$query = mysql_query(Select `salt` from record where `id` = '1012');
$row = mysql_fetch_array($query);
echo $row['salt'];

my output

sJ@>L0CeKotpH;kokFo1Z9BwE/ey8(i?nbpQ3ICY;]PRaD7TJE)I3@RYWZTSV]YkO2cduj6eeE0IFGuYE

So please suggest me how to get salt column value from the table.

The problem should be caused by echo $row['salt'];

Your column salt has a < in its value, so when echo it, the string after < will be discarded, you can try to run this:

<?php
echo 'sJ@>L0CeKotpH;kokFo1Z9BwE/ey8(i?nbpQ3ICY;]PRaD7TJE)I3@RYWZTSV]YkO2cduj6eeE0IFGuYE<R1GZ+OM2`Oto<W\`U:'
?>

Then you will find the result is

sJ@>L0CeKotpH;kokFo1Z9BwE/ey8(i?nbpQ3ICY;]PRaD7TJE)I3@RYWZTSV]YkO2cduj6eeE0IFGuYE

Edited :

echo htmlspecialchars('sJ@>L0CeKotpH;kokFo1Z9BwE/ey8(i?nbpQ3ICY;]PRaD7TJE)I3@RYWZTSV]YkO2cduj6eeE0IFGuYE<R1GZ+OM2`Oto<W\`U:')

Replace with bellow line then it will display as you want. But in other operations it will be same as it is.

echo str_replace("<","&lt;",$row['salt']);
echo htmlentities($row['salt']);

那应该做。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM