#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    1
    Rep Power
    0
    When I query my database ptnumber returns no data. Can anyone tell me why or how to fix this problem?
    The other two fields return the proper data, but the corresponding ptnumber's are missing.


    $result = mysql_query("SELECT * FROM crossref WHERE ptnumber LIKE 'IC%'");
    $num_rows = mysql_num_rows($result);


    //this while loop in within a table.

    while ($a_row = mysql_fetch_array($result))
    {
    print "<tr>n";
    print "<td>$a_row[manuf]</td> <td>$a_row[ptmumber]</td> <td>$a_row[description]</td>n";
    print "</tr>n";
    }

    Thanks, Curt
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Kearns, Utah, USA
    Posts
    16
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by spott100:
    When I query my database ptnumber returns no data. Can anyone tell me why or how to fix this problem?
    The other two fields return the proper data, but the corresponding ptnumber's are missing.


    $result = mysql_query("SELECT * FROM crossref WHERE ptnumber LIKE 'IC%'");
    $num_rows = mysql_num_rows($result);


    //this while loop in within a table.

    while ($a_row = mysql_fetch_array($result))
    {
    print "<tr>n";
    print "<td>$a_row[manuf]</td> <td>$a_row[ptmumber]</td> <td>$a_row[description]</td>n";
    print "</tr>n";
    }

    Thanks, Curt
    [/quote]

    Could it have anything to do with having $a_row[ptmumber], shouldn't it be $a_row[ptnumber]?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    1
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by computergfx:
    Could it have anything to do with having $a_row[ptmumber], shouldn't it be $a_row[ptnumber]?[/quote]


    Doh!
    Thanks, Curt
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Actually, it should be $a_row["ptnumber"], shouldn't it??

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  8. #5
  9. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Nope. Common misconception. Only in rare instances do you need to include quotes in an array index.
  10. #6
  11. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,646
    Rep Power
    4492
    Very interesting....

    You should put a comment in the PHP manual saying so, because they show it being done with quotes. Most people will take that as law, since that's how the manual shows it.

    ---jh
  12. #7
  13. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Actually, the manual shows both ways (from the PHP manual):

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>In PHP3 it is not possible to reference multidimensional arrays directly within strings. For instance, the following will not have the desired result:


    1
    2 $a[3]['bar'] = 'Bob';
    3 echo "This won't work: $a[3][bar]";
    4

    In PHP3, the above will output This won't work: Array[bar]. The string concatenation operator, however, can be used to overcome this:

    1
    2 $a[3]['bar'] = 'Bob';
    3 echo "This will work: " . $a[3][bar];
    4


    In PHP4, however, the whole problem may be circumvented by enclosing the array reference (inside the string) in curly braces:


    1
    2 $a[3]['bar'] = 'Bob';
    3 echo "This will work: {$a[3][bar]}";
    4[/quote]

    [This message has been edited by rod k (edited October 08, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo