SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    beginner level problem...plz help...

    hey guys im really new to php and and im trying to learn by mistakes... so i have a php page when im trying to execute it im getting error:
    Notice: Undefined variable: acct in C:\xampp\htdocs\banking\register_preview.php on line 8

    here is the code
    PHP Code:
    <html>
    <head>
    </head>
    <body bgcolor='#333333'>
    <?php

    include 'db_connect.php';
    $sql "SELECT * FROM  myacct WHERE acct='$acct'";
    $result mysql_query($sql) or die("SQL select statement failed");

    while (
    $row mysql_fetch_array($result))  {
             
    $acct=$row["acct"];
             
    $card=$row["card"];
             
    $name=$row["name"];
             
    $day=$row["day"];
    ?>
    <br><br><br><br><br><br><br><br>
     
    <table width="50%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#000000">
      <tr align="center">
        <td colspan="3"><font color="#00FF00" size="1" face="verdana">Welcome to your Banking System!</font></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width="37%" align="right"><font color="#00FF00" size="2" face="arial"><b>Account Number</b></font></td>
        <td width="7%" align="center"><font color="#00FF00" size="2" face="arial">:</font></td>
        <td width="56%"><font color="#00FF00" size="2" face="arial"><b><?php echo"$acct"?></b></font></td>
      </tr>
      <tr>
        <td align="right"><font color="#00FF00" size="2" face="arial"><b>Identity Card</b>
          </font></td>
        <td align="center"><font color="#00FF00" size="2" face="arial">:</font><br>
        </td>
        <td><font color="#00FF00" size="2" face="arial"><b><?php echo"$card"?></b></font></td>
      </tr>
      <tr>
        <td align="right"><font color="#00FF00" size="2" face="arial"><b>Full Name</b></font></td>
        <td align="center"><font color="#00FF00" size="2" face="arial">:</font><br>
        </td>
        <td><font color="#00FF00" size="2" face="arial"><b><?php echo"$name $pword"?></b></font></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td align="center">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr align="center">
        <td colspan="3"> <form action='main.php' method='post'>
            <input type='submit' value='Proceed'>
          </form></td>
      </tr>
    </table>
    <?php
       
    }
    ?>
    </body>
    </html>
    plz explain what is going on and how to solve such issues.... im really at beginner level so instead of laughing over my stupidity plz help...

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sql "SELECT * FROM  myacct WHERE acct='$acct'"
    You are trying to use $acct without ever declaring/defining it.

    My guess is this is supposed to come from a URL query? Or maybe a form submission where the user chooses an account to view?

    In which case you would need to add this to your page
    PHP Code:
    $acct intval($_REQUEST['acct']); //assuming it is a number 
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •