mafazinfo Posted April 2, 2013 Share Posted April 2, 2013 <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","12345678");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'];$fld2 ='25';mysql_close($con); ?><?php echo $jval; ?><?php echo $fld1; ?> PROBLEM IS IF I REPLACE VARIABLE $c FOR $jval WILL NOT WORK $result2 = mysql_query("SELECT * FROM tblprocode where code='". $jval."';"); ITS PRINT LIKE THIS <?php echo $jval; ?> PRINT AS D50<?php echo $fld1; ?> NOTHING ITS BLANK IF I REPLACE VARIABLE $c FOR $jval WILL NOT WORK $result2 = mysql_query("SELECT * FROM tblprocode where code='". $c."';"); ITS PRINT LIKE THIS <?php echo $jval; ?> PRINT AS D50<?php echo $fld1; ?> PRINT RECORD DATA Quote Link to comment https://forums.phpfreaks.com/topic/276421-php-variable-problem/ Share on other sites More sharing options...
DaveyK Posted April 2, 2013 Share Posted April 2, 2013 (edited) Please put your code in [ code ] [ /code ] tags... Also, I have no idea why you are trying to write JS in PHP in JS here <script type="text/javascript"> var jvalue = form1.code1.value; <?php $abc = "<script>document.write(jvalue)</script>"?> </script> Why dont you use Ajax? Edited April 2, 2013 by DaveyK Quote Link to comment https://forums.phpfreaks.com/topic/276421-php-variable-problem/#findComment-1422422 Share on other sites More sharing options...
mafazinfo Posted April 2, 2013 Author Share Posted April 2, 2013 i want to use input box name code1 typed text, should search sql recordset and display in textbox code2.value example : code1 input box if typed as D10 should display in code2 input box as DIAL 10 <?php echo $jval; ?> // its printing data<?php echo $fld1; ?> // its printing data <?php echo $abc; ?> // its printing data but sql quary not passing value Quote Link to comment https://forums.phpfreaks.com/topic/276421-php-variable-problem/#findComment-1422454 Share on other sites More sharing options...
mafazinfo Posted April 2, 2013 Author Share Posted April 2, 2013 Please put your code in [ code ] [ /code ] tags... Also, I have no idea why you are trying to write JS in PHP in JS here <script type="text/javascript"> var jvalue = form1.code1.value; <?php $abc = "<script>document.write(jvalue)</script>"?> </script> Why dont you use Ajax? Thank you for your suggestion, i'm not advanced user, please help me what was the wrong ?? i want to use input box name code1 typed text, should search sql recordset and display in textbox code2.value example : code1 input box if typed as D10 should display in code2 input box as DIAL 10 <?php echo $jval; ?> // its printing data <?php echo $fld1; ?> // its printing data <?php echo $abc; ?> // its printing data but sql quary not passing value Quote Link to comment https://forums.phpfreaks.com/topic/276421-php-variable-problem/#findComment-1422455 Share on other sites More sharing options...
DaveyK Posted April 2, 2013 Share Posted April 2, 2013 Do you have error reporting turned on? If not, turn it on. Quote Link to comment https://forums.phpfreaks.com/topic/276421-php-variable-problem/#findComment-1422456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.