SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to display a php-message if a mysql field has no data?

    Hi, me again

    Basically i want to display a php-message if a mysql field has no data.
    I think about the following procedure:

    1 User selects A
    2 A has a variable_A that is being sent to mysql_db
    3 if variable_A has no value a php-message must be displayed in a .php file


    Any suggestions
    D-flyer

  2. #2
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    $query 
    mysql_query("select fieldname from tablename where clause");

    //no results. Fieldname must be NULL
    if (mysql_num_rows($query) < 1) echo "Error, empty field!";

    //fieldname is not null!
    else {
      while (
    $result mysql_fetch_object($query)) {
        
    /* do your stuff here with $result->fieldname */
      
    }


  3. #3
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx Vegata aka Cupid

    Gonna try your suggestion immediately.

    D

  4. #4
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It could be the Breezer or the fact that i use UD to write a bunch of my code(meanwhile i'm lerning to hardcode) but it ain't working

    PHP Code:
    <?php
    $rsPartyDetail
    =$connTicketscene->Execute("SELECT * FROM tblfeest WHERE naam = '" . ($rsPartyDetail__MMColParam) . "Error, empty field") or DIE($connTicketscene->ErrorMsg());
       
    if (
    $rsPartyDetail_numRows) < 1)  echo " ";

    else {
      while (
    $result mysql_fetch_object($rsPartyDetail)) {
       
    $rsPartyDetail_numRows=0;
       
    $rsPartyDetail__totalRows=$rsPartyDetail->RecordCount();
       }
    }

    ?>

  5. #5
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by D-flyer
    It could be the Breezer or the fact that i use UD to write a bunch of my code(meanwhile i'm lerning to hardcode) but it ain't working

    PHP Code:
    <?php
    $rsPartyDetail
    =$connTicketscene->Execute("SELECT * FROM tblfeest WHERE naam = '" . ($rsPartyDetail__MMColParam) . "Error, empty field") or DIE($connTicketscene->ErrorMsg());
       
    if (
    $rsPartyDetail_numRows) < 1)  echo " ";

    else {
      while (
    $result mysql_fetch_object($rsPartyDetail)) {
       
    $rsPartyDetail_numRows=0;
       
    $rsPartyDetail__totalRows=$rsPartyDetail->RecordCount();
       }
    }

    ?>
    Eep.. I hope it's doing everything right.. For instance, do you have a field in 'tblfeest' named 'naam'?

    Also, I'm not sure what this is doing.. the error message is inside the select query. This is incorrect code. The error message is supposed to appear in this line:

    if ($rsPartyDetail_numRows) < 1) echo "Error, empty field";

    I'd really recommend you hardcoding this.

  6. #6
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it's also the breezer because i was trying your(Cupid) code in a wrong page.

    I am gonna try it on the good page.

  7. #7
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To dissy, can't focus go to sleep

    Bye guys


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
  •