SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can i remove notice from my php pages

    Hi everybody,
    I am making my website using php now my script is running successsfully but every page it gives a notice regarding my variable how can i remove this "
    Notice: Undefined index: qid in e:\inetpub\wwwroot\try\new.php on line 3

    Notice: Undefined index: B1 in e:\inetpub\wwwroot\try\new.php on line 4

    Notice: Undefined index: S1 in e:\inetpub\wwwroot\try\new.php on line 5"
    what is this ?Is this error or warnning?Plz help me.my code is as follows:
    <?php
    include('conn.php');
    $qid= $_POST['qid'];
    $submit= $_POST['B1'];
    $text=$_POST['S1'];
    if ($submit=="Button")

    {
    $ins= "update student set ans='$text' where qid=$qid";
    mysql_query($ins) or
    die ("Cannot insert into database ");
    header('location: /try/no.html');

    }
    ?>
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>

    </HEAD>

    <BODY>
    <p align="center">the question was<input type="text" name="s2" rows="2" value ="<? echo $_REQUEST['quest']; ?>" cols="50" ></textarea></p>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
    <input name="qid" type="hidden" value="<?php echo $_REQUEST['qid']; ?>" >
    <p align="center">What is your answer?<textarea rows="2" name="S1" cols="20"></textarea></p>
    <p align="center"><input type="submit" value="Button" name="B1"></p>
    </form>

    </BODY>
    </HTML>

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $qid = empty($_POST['qid']) ? '' $_POST['qid'];
    $submit = empty($_POST['B1']) ? '' $_POST['B1'];
    $text = empty($_POST['S1']) ? '' $_POST['S1']; 
    The above is just a short way of doing:
    PHP Code:
    if(empty($_POST['qid'])){
        
    $qid '';
    } else {
        
    $qid $_POST['qid'];


  3. #3
    My precious!!! astericks's Avatar
    Join Date
    Mar 2002
    Location
    Vancouver, BC
    Posts
    1,971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    at the top of the parse, set the following:

    PHP Code:
    error_reporting(E_PARSE); 
    Note: this will only allow parse errors to be shown.

  4. #4
    3MTA3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    1,016
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could also turn off notices in the error reporting if you have access to php.ini:
    ; - Show all errors, except for notices
    ;
    error_reporting = E_ALL & ~E_NOTICE

  5. #5
    SitePoint Addict Tim_Rogovets's Avatar
    Join Date
    Aug 2003
    Location
    Odessa, Ukraine
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also you can add '@' to the start of any operator to make php silent when performing the current operation. No errors, warnings, notices would be output.
    I.E.:
    PHP Code:
    @$qid$_POST['qid']; 
    CEO of Grandiz! - a team based in Odessa, Ukraine.
    Designing and developing sophisticated web apps on CodeIgniter!

  6. #6
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you markl999


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
  •