can any body help me with the below code correct code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fsonic
Forum Newbie
Posts: 2
Joined: Wed Dec 20, 2017 5:13 pm

can any body help me with the below code correct code

Post by fsonic »

Notice: Undefined index: memberID in /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php on line 81

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' in /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php:82 Stack trace: #0 /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php(82): PDO->prepare('SELECT * FROM t...') #1 {main} thrown in /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php on line 82

above was the result can anybody help me with this

Code: Select all

<?php require_once('includes/config.php'); 
	$username = $_REQUEST['memberID'];
	$stmt = $db->prepare("SELECT * FROM transfer WHERE username ='$memberID'");
	$stmt->execute();
	while($row=$stmt->fetch(PDO::FETCH_ASSOC))
	{
		?>
		<tr>
		<td><?php echo $row['memberID']; ?></td>
		<td><?php echo $row['username']; ?>
		<td><?php echo $row['names']; ?></td>
		<td><?php echo $row['accountno']; ?></td>
		<td><?php echo $row['gender']; ?></td>
		<td><?php echo $row['dob']; ?></td>
		<td><?php echo $row['typeofaccount']; ?></td>
		<td><?php echo $row['amount']; ?></td>
		<td><?php echo $row['active']; ?></td>
		<td><a href="edit.php?Edit=<?php echo $row['memberIDid']; ?>">
            <button class="btn btn-Primary">Transfer</button></a>
            </td> 
	 
		 
		</tr>
		<?php
	}
	?>
benanamen
Forum Newbie
Posts: 18
Joined: Sun Nov 15, 2015 11:57 am

Re: can any body help me with the below code correct code

Post by benanamen »

Problem 1. You create $username and then don't use it.
Problem 2. You have a variable $memberID that comes out of nowhere that you do not use.
Problem 3. The table transfer does not have a column named or spelled username
Problem 4. You never ever put variables in a query. You need to use Prepared Statements

username != Username != UserName != user_name != User_Name

Do not SELECT *. Specify the columns you want.

You need to use htmlentities on your DB output
fsonic
Forum Newbie
Posts: 2
Joined: Wed Dec 20, 2017 5:13 pm

Re: can any body help me with the below code correct code

Post by fsonic »

Notice: Undefined index: memberID in /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php on line 81

Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'username' in 'where clause' in /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php:82 Stack trace: #0 /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php(82): PDO->prepare('SELECT * FROM t...') #1 {main} thrown in /opt/lampp/htdocs/wwwroot/firstrepus/transfersta.php on line 82

above was the result can anybody help me with this


i wont to select with the login user

Code: Select all

CREATE TABLE IF NOT EXISTS `transfer` (
  `trans_id` int(11) NOT NULL,
  `memberID` int(11) NOT NULL,
  `accountnumber` varchar(20) NOT NULL,
  `bankname` varchar(100) NOT NULL,
  `accountname` varchar(200) NOT NULL,
  `transferamount` varchar(200) NOT NULL,
  `send` varchar(20) DEFAULT NULL,
  `transferdate` datetime DEFAULT NULL,
  PRIMARY KEY (`trans_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


  <table cellspacing="0" width="100%" id="example" class="table table-striped table-hover table-responsive">
              <thead>
                  <tr>
                      <th class="bg-success"><strong>S/N</strong></th>
                      <th class="bg-success"><strong>A/C Number</strong></th>
                      <th class="bg-success"><strong>Bank Names</strong></th>
                      <th class="bg-success"><strong>A/C Names</strong></th>
                      <th class="bg-success"><strong>Amount</strong></th>
                      <th class="bg-success"><strong>Transfer</strong></th>
                      <th class="bg-success"><strong>Date</strong></th>
                      
                      
                     </tr>
              </thead>
          <tbody>
          <?php require_once('includes/config.php'); 
            $memberID = 'memberID';
            $stmt = $db->prepare("SELECT * FROM transfer");
          $stmt->execute();
          while($row=$stmt->fetch(PDO::FETCH_ASSOC))
          {
              ?>
              <tr>
              <td><?php echo $row['memberID']; ?></td>
              <td><?php echo $row['accountnumber']; ?>
              <td><?php echo $row['bankname']; ?></td>
              <td><?php echo $row['accountname']; ?></td>
              <td><?php echo $row['transferamount']; ?></td>
              <td><?php echo $row['send']; ?></td>
              <td><?php echo $row['transferdate']; ?></td>
             
           
               
              </tr>
              <?php
          }
          ?>
pardeeptrivedi
Forum Newbie
Posts: 5
Joined: Tue Feb 06, 2018 1:33 am

Re: can any body help me with the below code correct code

Post by pardeeptrivedi »

First you have problem in username because you use memberiD
$stmt = $db->prepare("SELECT * FROM transfer WHERE username ='$memberID'");
REPLACE WITH
$stmt = $db->prepare("SELECT * FROM transfer WHERE username ='$username'");
Post Reply