0

The below line generates this error. Can anyone gives me a solution

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\MySite\php files\approve_page.php on line 25

$query = "UPDATE transaction SET approved_status='1' WHERE account_number='$account_number' AND tran_id='$_POST['tran_id']'";
2
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by heshanm
0

Use the following

$query = "UPDATE transaction SET approved_status='1' WHERE account_number='$account_number' AND tran_id='".$_POST['tran_id']."'";

You should consider the use of mysql_real_escape_string() to avoid SQL injection problems.

Edited by mwasif: n/a

0

Thanks it works...

Can you help me in these set of coding. I want to approve records one by one. The below coding works and displays the message "Details have been succesfully approved". But nothing will happen in the transaction table.

The "approved_status" column remains the same . The default value of "o" is there.

<?php
   
$connect=mysql_connect('localhost','root','');
mysql_select_db('bank',$connect);

if(isset($_POST['account_number']))
    $account_number=$_POST['account_number'];
else
    $account_number='';
	
if(isset($_POST['tran_id']))
    $tran_id=$_POST['tran_id'];
else
    $tran_id='';
	
 
$query = "UPDATE transaction SET approved_status='1' WHERE account_number='$account_number' AND tran_id='$tran_id'";
$result= mysql_query($query) or die(mysql_error());

if ($result)
   {
      echo "Details have been successfully approved";
   }
   
?>
0

It looks like the query is not building correctly. Print your query to identify the problem. Place the following code between line 17 and 18 and post the output here.

echo $query;
0

Here is the output.

UPDATE transaction SET approved_status='1' WHERE account_number='' AND tran_id=''Details have been successfully approved

0

In this MySQL statement, there is no account number and transaction id.

UPDATE transaction SET approved_status='1' WHERE account_number='' AND tran_id=''

Are you providing this information?

0

At the begining of my coding i defined those parameters

if(isset($_POST['account_number']))
    $account_number=$_POST['account_number'];
else
    $account_number='';
	
if(isset($_POST['tran_id']))
    $tran_id=$_POST['tran_id'];
else
    $tran_id='';
0

Since i am new to the PHP I didn't get it..

This program works like this.In my main page (cashsup_page.php) there is a link to Approve records. When a user clicks on that it redirects to another page (check_transactions.php) where he has to enter the account number. When he submitted the account number,the relevant details will apppear in another page.(approve_transactions.php). It contains "approve" button which links to the above coding (approve_page.php)

My transaction table looks like this.tran_id is the primary key of the table.

transaction (tran_id, account_number,___)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.