Professional Web Applications Themes

bug in code - can't find it! - PHP Development

Ok, after all of the discussion on posting, I'm afraid to post. Unfortunately, no one I know is a programmer, and I am a beginner. I can normally figure out what I've done wrong, but I'm missing something here. Ok, here is my query and the bit of code I can't figure out: $query = "SELECT * from apt_user_t a, apt_company_t b "; $query .= "WHERE a.user_cd = b.user_cd "; $query .= "ORDER BY a.username"; $search_results = mysql_query($query) or die("Select Failed!"); while ($search_result2 = mysql_fetch_array($search_results)) { <INPUT TYPE="checkbox" NAME="<? echo $search_result2['user_cd'];?>" SIZE="20" MAXLENGTH="50" VALUE="<?if ($search_result2[a.retired_flag] == 1){?>CHECKED<?}?>"> <?echo $search_result2[a.retired_flag]?> } ...

  1. #1

    Default bug in code - can't find it!

    Ok, after all of the discussion on posting, I'm afraid to post.
    Unfortunately, no one I know is a programmer, and I am a beginner. I can
    normally figure out what I've done wrong, but I'm missing something here.

    Ok, here is my query and the bit of code I can't figure out:

    $query = "SELECT * from apt_user_t a, apt_company_t b ";
    $query .= "WHERE a.user_cd = b.user_cd ";
    $query .= "ORDER BY a.username";

    $search_results = mysql_query($query) or die("Select
    Failed!");
    while ($search_result2 = mysql_fetch_array($search_results))
    {
    <INPUT
    TYPE="checkbox"
    NAME="<? echo $search_result2['user_cd'];?>"
    SIZE="20"
    MAXLENGTH="50"
    VALUE="<?if ($search_result2[a.retired_flag] == 1){?>CHECKED<?}?>"> <?echo $search_result2[a.retired_flag]?>
    }
    Nothing shows up with the echo or the value. I only included this
    checkbox, but all of the other values show up fine. Can someone give me a
    hint?



    Amanda McComb Guest

  2. #2

    Default Re: [PHP] bug in code - can't find it!

    just a little point; u can replace
    <?echo $search_result2[a.retired_flag]?>
    by <?=$search_result2[a.retired_flag]?>
    which is better imho.

    ----
    AciD



    On Wed, 6 Aug 2003 14:57:23 -0700, Jennifer Goodie
    <goodieapollointeractive.com> wrote:
    >
    >> Ok, here is my query and the bit of code I can't figure out:
    >>
    >> $query = "SELECT * from apt_user_t a, apt_company_t b ";
    >> $query .= "WHERE a.user_cd = b.user_cd ";
    >> $query .= "ORDER BY a.username";
    >>
    >> $search_results = mysql_query($query) or die("Select
    >> Failed!");
    >> while ($search_result2 = mysql_fetch_array($search_results))
    >> {
    >> <INPUT
    >> TYPE="checkbox"
    >> NAME="<? echo $search_result2['user_cd'];?>"
    >> SIZE="20"
    >> MAXLENGTH="50"
    >> VALUE="<?if ($search_result2[a.retired_flag] ==
    >> 1){?>CHECKED<?}?>"> <?echo $search_result2[a.retired_flag]?>
    >> }
    >> Nothing shows up with the echo or the value. I only included this
    >> checkbox, but all of the other values show up fine. Can someone give me
    >> a
    >> hint?
    >
    > Mysql does not prefix returned columns with table_name., so there's
    > probably
    > no "a.retired_flag" index in your array. A simple way to check this
    > would
    > be to print_r($search_result2). If you have a column named retired_flag
    > in
    > both table a and table b and you specifically want the one from table a
    > in
    > your result set you are going to have to alias it to a different name in
    > your query, i.e. "SELECT *, a.retired_flag as r_flag"
    >
    >
    >


    --
    [url]www.cpm-fr.com[/url]
    Acid Guest

  3. #3

    Default Re: [PHP] bug in code - can't find it!

    AciD wrote:
    > just a little point; u can replace
    > <?echo $search_result2[a.retired_flag]?>
    > by <?=$search_result2[a.retired_flag]?>
    > which is better imho.
    and you're entitled to it, but it's not better. Shorter isn't always better.

    Your code will break if enable_short_open_tags is disabled in php.ini or
    an .htaccess file. Sure, it's on by default, but some people turn it
    off, especially when dealing with XML a lot.

    --
    ---John Holmes...

    Amazon Wishlist: [url]www.amazon.com/o/registry/3BEXC84AB3A5E/[/url]

    PHP|Architect: A magazine for PHP Professionals [url]www.phparch.com[/url]




    John W. Holmes Guest

  4. #4

    Default Re: [PHP] bug in code - can't find it!

    Is it realy so? I remember someone noting on this list it also work if
    short tags are off.
    I have never tested it and I'm not going to restart our server now, but
    I will try it at home.

    John W. Holmes wrote:
    > AciD wrote:
    >
    >> just a little point; u can replace
    >> <?echo $search_result2[a.retired_flag]?>
    >> by <?=$search_result2[a.retired_flag]?>
    >> which is better imho.
    >
    >
    > and you're entitled to it, but it's not better. Shorter isn't always
    > better.
    >
    > Your code will break if enable_short_open_tags is disabled in php.ini or
    > an .htaccess file. Sure, it's on by default, but some people turn it
    > off, especially when dealing with XML a lot.
    >
    Marek Kilimajer Guest

Similar Threads

  1. Need code to find 2-day old files
    By Adams-Blake Co. in forum PHP Development
    Replies: 2
    Last Post: January 7th, 12:32 AM
  2. I can find it, why can't my code?
    By PaulNaude in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: October 12th, 01:40 PM
  3. can't find AE opendoc sample code
    By Keith Wiley in forum Mac Programming
    Replies: 4
    Last Post: September 6th, 02:20 PM
  4. How to find out the User Name The ASP.NET is run under in the code
    By David Shvartsman in forum ASP.NET Security
    Replies: 3
    Last Post: August 11th, 04:05 PM
  5. [PHP] bug in code - can't find it!
    By Amanda McComb in forum PHP Development
    Replies: 2
    Last Post: August 6th, 09:55 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139