PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jun 17, 2018 10:57 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Dec 20, 2017 6:19 pm 
Offline
Forum Newbie

Joined: Wed Dec 20, 2017 6:13 pm
Posts: 2
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
Syntax: [ Download ] [ Hide ]
<?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
        }
        ?>


Top
 Profile  
 
PostPosted: Wed Dec 20, 2017 7:14 pm 
Offline
Forum Newbie

Joined: Sun Nov 15, 2015 12:57 pm
Posts: 17
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


Top
 Profile  
 
PostPosted: Wed Dec 20, 2017 7:31 pm 
Offline
Forum Newbie

Joined: Wed Dec 20, 2017 6:13 pm
Posts: 2
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

Syntax: [ Download ] [ Hide ]
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
          }
          ?>


Top
 Profile  
 
PostPosted: Tue Feb 06, 2018 2:59 am 
Offline
Forum Newbie

Joined: Tue Feb 06, 2018 2:33 am
Posts: 5
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'");


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Google [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group