无法使用 PostgreSQL 查询以 php 形式显示变量的完整值



(初学者( 尽管使用了许多论坛,但我找不到解决方案。 我查询PostgreSQL并尝试在php页面的文本字段中显示结果。

查询:

$sql3 = "select * from matable where code_tranche = $1" ;

然后

$marequete = pg_query_params(pg_connect("host=$server port=$port dbname=$base user=$_SESSION[identifier] password=$_SESSION[password]"),
$sql3, array($code_tranche)) ;

然后,html:

<body class = "imagemenuu">
<div >
<form >
<h4>Operation <?php echo $code_tranche ?></h4>
<?php
if (pg_num_rows($marequete) ==0) {
echo "<h5> The operation "$code_tranche' does not exist </h5>" ;
}
else {
line = pg_fetch_assoc($marequete) ;
var_dump($line[nomope]) ;
}
?>
<p class="psga" >operation name: <input type="text" size='60' name="nom_ope" value=<?php echo"'$ligne[nomope]'" ; ?> class = "alert alert-info" >   
</div>
</form>
</body>

如前所述,字段nom_ope显示变量$line的字段名称的内容,除非该字段包含 ' ex:phase 110,非常好,但 L 而不是L'hopital

我试过:

echo $ligne[nomope]

结果:L'hopital,但只是阶段

addslashes($line[nomope])

不比L'\hopital好。

htmlentities($line[name], ENT_QUOTES)

也好不到哪里去。

value=<?php echo htmlspecialchars($ligne[nomope]) ; ?>

不可能。。。

简而言之,根据所使用的功能,要么我有整个字段,而 ' 之后没有任何内容,要么我有带有'的文本,对于其他情况,我只有字段的第一个单词。

哪种技术可以让我获得完整的结果,'或不?

我忘记了属性中的">: 所以现在:

value="<?php echo $ligne['nomope'] ; ?>"

它工作正常。

最新更新