php sql recordeseet无法通过变量连接

时间:2013-04-02 08:58:30

标签: php javascript sql variables record

<form name="form1"/>

<input type="text" name="code1" value="D50" size="7" maxlength="10" onblur="chkidpro(this.value,'provider1');" />

<input type="text" name="code2" value="" size="7" maxlength="10"/>

<form/>

<script type="text/javascript">

var jvalue = form1.code1.value;

<?php $abc = "<script>document.write(jvalue)</script>"?>

</script>

<?PHP $con = mysql_connect("localhost","abc_one","PASS");

mysql_select_db("abc_one", $con);

$c= "D50";

$jval = $abc;

$result2 = mysql_query("SELECT * FROM tblprocode where code='". $c."';");

$tab = mysql_fetch_array($result2);

$fld1 = $tab['card'];

mysql_close($con);

?>

<?php echo $jval; ?>

<?php echo $fld1; ?>

如果我替换 $result2 = mysql_query("SELECT * FROM tblprocode where code='". $jval."';");

<?php echo $abc; ?> // its print as D50

<?php echo $jval; ?> // its print as D50

<?php echo $fld1; ?> // its not print, its blank

如果我替换 $result2 = mysql_query("SELECT * FROM tblprocode where code='". $c."';");

<?php echo $abc; ?> // its print as D50

<?php echo $jval; ?> // its print as D50

<?php echo $fld1; ?> // its print record data

请帮帮我什么错?

1 个答案:

答案 0 :(得分:0)

我认为您应该使用trim函数$jval = trim($abc);