Jump to content

php variable problem


mafazinfo

Recommended Posts

<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

 

Link to comment
https://forums.phpfreaks.com/topic/276421-php-variable-problem/
Share on other sites

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?

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
 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.