Jump to content

Error occurred while modifying customer details


heshan

Recommended Posts

Hi,

 

I want to edit data if needed in my form. The particular set of details were searched based on Account Number.The data retrived from 2 tables.

 

account_details (account_number, _____)

 

account(account_number,____)

 

Here i have posted my modify_data.php page which returns an error message saying,

 

Customer details  Column 'account_number' in where clause is ambiguous

 

<form name="form1" action="approve_data.php">
  <fieldset>
  <legend class="cap">Customer details</legend>
  <table width="75%" border="0" cellspacing="0" cellpadding="5" align="center">
  
  <?php
  
   //initilize variables
            
                 $full_name = '';
                 $name_with_initials = '';
	 $phone_number = '';
                 $address = '';
                 $gender = '';
	 $date_of_birth = '';
	 $account_type = '';
	 $fd_period = '';

$sql =sprintf("SELECT account_details. full_name,phone_number,address,gender,date_of_birth,account.name_with_initials,account_type,fd_period"." FROM account_details,account"." WHERE `account_number`='%s'", mysql_real_escape_string($_POST['account_number']) );


$result=mysql_query($sql) or die( mysql_error() );

  if( mysql_num_rows($result)<1 )
  {
    echo "<p>No records found.</p>";
  }	
  
   
$query ="SELECT account_details. full_name,phone_number,address,gender,date_of_birth,account.name_with_initials,account_type,fd_period"." FROM account_details,account"." WHERE account_details.account_number=account.account_number";

$result = mysql_query($query) or die(mysql_error());
while ($row=mysql_fetch_array($result)){
                 

// replace blank variables with variables from the database	  

                $full_name = $row['full_name'];
                $name_with_initials = $row['name_with_initials'];
	$phone_number = $row['name_with_initials'];
                $address = $row['address'];
                $gender = $row['gender'];
	$date_of_birth = $row['date_of_birth'];
	$account_type = $row['account_type'];
	$fd_period = $row['fd_period'];


}

  ?>
                 <tr>
                  <td> </td>
                  <td class="title02"> </td>
                  <td> </td>
                  <td> </td>
                 </tr>
                                          
                 <tr height="30">
                  <td width="10%"> </td>

               
                  
                        <td width="25%" class="title02" align="left">Full name</td>
                    <td width="55%" class="attribute1" align="left"><label>
              <input type="text" name="full_name" value="<?php echo $row['full_name']; ?>" class="attribute1" />
              </label></td>
                  <td width="10%"> </td>
                 </tr>
                 <tr height="30">
                  <td> </td>
                  <td class="title02" align="left">Name with initials</td>
                  <td class="attribute1" align="left"><input type="text" name="name_with_initials" value="<?php echo $row['name_with_initials']; ?>                                                                        " class="attribute1" /></td>
                 </tr>
                   <tr height="30">
                  <td width="10%"> </td>


                  <td width="25%" class="title02" align="left">Phone Number</td>
                  <td width="55%" class="attribute1" align="left"><label>
                  <input type="text" name="phone_number" value="<?php echo $row['phone_number']; ?>" class="attribute1" />
                  </label></td>
                  <td width="10%"> </td>
                 </tr>
                       <tr height="30">
                  <td width="10%"> </td>


                  <td width="25%" class="title02" align="left">Address</td>
                  <td width="55%" class="attribute1" align="left"><label>
                    <textarea name="address" id="textarea" <?php echo $row['address']; ?> cols="45" rows="5"></textarea>
                  </label></td>
                  <td width="10%"> </td> 
    <tr height="30">
                        
                  <td> </td>
                  <td class="title02" align="left">Gender</td>
                  <td class="attribute1" align="left"><label>
                    <select name="gender" id="select">
                           <option selected="selected"><?php echo $row['gender']; ?></option>
                      <option value="male">Male</option>
                            <option value="female">Female</option>
                  </select>
                  </label></td>
    <tr height="30">
                  <td> </td>
                  <td class="title02" align="left">Date of birth</td>
                  <td class="attribute1" align="left"><input type="Text" id="demo3" name="date_of_birth" value="<?php echo $row['date_of_birth'];                    ?>" maxlength="25" size="25"/><img src="../images/cal.gif" onClick= "javascript:NewCssCal('demo3','yyyyMMdd')" style="cursor:pointer"/> </td>
    </tr>
    <tr height="30">
        <td width="10%" height="41"> </td>
        <td width="25%" class="title02" align="left">Account Type</td>
        <td width="65%" align="left" bgcolor="#FFFFFF" class="attribute1">
        <select name="account_type" onChange="fd_show(this.value)">
            <option selected="selected"><?php echo $row['account_type']; ?></option>
            <option value="savings_investment">Savings Investment</option>
            <option value="shakthi" >Shakthi</option>
            <option value="surathal">Surathal</option>
            <option value="abhimani_plus">Abhimani Plus</option>
            <option value="yasasa">Yasasa Certificates</option>
            <option value="fd">Fixed Deposits</option>
          </select> </td>
    <tr height="30">
      <td colspan="4">
          <div id="fd_box" style="visibility: hidden;">
          <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
            <tr height="30"> </tr>
            <tr height="30">
              <td width="10%"></td>
              <td width="25%" class="title02" align="left">FD period</td>
              <td width="55%" class="attribute1" align="left"><select name="fd_period">
                  <option selected="selected"><?php echo $row['fd_period']; ?></option>
                  <option value="< 1">less than 1 year</option>
                  <option value="1-3 years" >1-3 years</option>
                  <option value="> 3">more than 3 years</option>
                  <option value="il">immediate loan</option>
              </select></td>
              <td width="10%"></td>
            </tr>
            <tr height="1"></tr>
<tr height="30"></tr>
          </table>    
         
      <tr height="30">
        <td> </td>
        <td width="25%" class="title02" align="left"> </td>
        <td width="55%" align="left" bgcolor="#FFFFFF" class="attribute1"> </td>
  </table>
  <p align="center"> </p>
    <p align="center">
      <a href="approve_data.php">
       <label>
        <input type="submit" name="button2" id="button2" value="Modify" />
      </label></a>
      
          
    <label>
        <input type="submit" name="button2" id="button2" value="Help" />
      </label>
    </p>
  </fieldset>
  </td>
  <td width="5%"> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td align="center"> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td><font color="red" size="1" ></font></td>
    <td> </td>
  </tr>
                      
         
                 
                      
  </table>
<p align="center">    </p>
  </fieldset>
</td>
            <td width="5%"> </td>
         </tr>


           <tr>


             <td> </td>
             <td> </td>
             <td> </td>
  </tr>
           
           
           
           <tr>
             <td> </td>
             <td align="center"> </td>
             <td> </td>
  </tr>
           <tr>
             <td> </td>
                            <td><font color=red size="1" ></font></td>
             <td> </td>
  </tr>
         </table>
    
</form>

 

Link to comment
Share on other sites

When user changes the data and click on "Approve" button the data passed to approve_data.php page. But the error comes with that modify_data.php pahe which contains only this query....

 

<?php
  
$connect=mysql_connect('localhost','root','');
mysql_select_db('bank',$connect);
  
            
                 $full_name = '';
                 $name_with_initials = '';
	  $phone_number='';
                 $address = '';
                 $gender='';
                 $date_of_birth='';
	 $account_type='';
	 $fd_period='';

      
                $account_number =$_POST['account_number'];
                $full_name =$_POST['full_name'];
                $name_with_initials =$_POST['name_with_initials'];
	$phone_number=$_POST['phone_number'];
                $address =$_POST['address'];
                $gender =$_POST['gender'];
                $date_of_birth =$_POST['date_of_birth'];
	$account_type =$_POST['account_type'];
	$fd_period =$_POST['fd_period'];

                

$result1 = mysql_query("UPDATE  `account_details` SET `full_name` = '{full_name}',`phone_number`='{$phone_number}',  `address` ='{$address}', `gender`='{$gender}' `date_of_birth`='{$date_of_birth}' WHERE `account_number`={$_POST['account_number']}") or die (mysql_error()) ;     

$result2 = mysql_query("UPDATE  `account` SET `name_with_initials` = '{name_with_initials}',`account_type`='{$account_type}',  `fd_period` ='{$fd_period}' WHERE `account_number`={$_POST['account_number']}") or die (mysql_error()) ;                   
              

               if($result1){
                  echo "Your information has been successfully added to the database.";
              }else{
                 echo "Failed";
              }
		  
	  if($result2){
                  echo "Your information has been successfully added to the database.";
              }else{
                 echo "Failed";
              }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.