Click here to Skip to main content
15,937,602 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Team, I am new on this website and also in PHP :). I need some help from experts, and I am sure my code is not up to the mark but still working on it.
My code is as below, what I do here is, I got evaluation ID from javascript and shift it to a PHP variable and it's printing that required value as well.
but when I am trying to put this variable in PHP Query, it's not passing that values due to which my PHP code is not working. However, if I pass a static value it's working fine.

$sql = 'SELECT * FROM eval where evaid="11075"';

I want to pass this $eid into this mentioned query but it's not working. Please help.

What I have tried:

			$eid = "' + response[0].EvaluationId + '";
			echo $eid;

			$division = "' + response[0].Division + '";
			echo $division;

   	$dbhost = 'localhost'; 
  	 $dbuser = 'root';
  	 $dbpass = '123456';
  	 $conn = mysql_connect($dbhost, $dbuser, $dbpass);
 	  if(! $conn ) {
	      die('Could not connect: ' . mysql_error());
 	  $sql = 'SELECT * FROM eval where evaid="11075"'; 

 	  $retval = mysql_query( $sql, $conn );
 	  if(! $retval ) {
 	     die('Could not get data: ' . mysql_error());
 		while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {

if ($row['division'] == "CRM Sales - Support" AND $row['etype'] == "dddd")
echo "downgrade ";
elseif ($row['division'] == "CRM Sales - Support" AND $row['etype'] == "upre")
echo "update";
elseif ($row['division'] == "CRM Sales - Support" AND $row['etype'] == "Ponly")
echo "Party";
elseif ($row['division'] == "DME")
echo "devide me equal";
echo "Open Ended";

Updated 16-Oct-18 2:37am
SiFinances 28-Oct-18 7:06am    
You can't do this in this way. Variable from js you can pass to php in ajax query for example. JS variable are set after render page, PHP work before.

1 solution

Not only are you using deprecated MySQL extension[^], but also your SQL query is susceptible to SQL injection[^], learn to use PHP Prepared Statements[^] instead.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900