[PHP] Bizarre SQl, if issue....

Ask a Question related to PHP Development, Design and Development.

  1. #21

    Default Re: [PHP] Bizarre SQl, if issue....

    * Thus wrote Mike At Spy (spycobalt@spyproductions.com):
    >
    > Off hand, I would agree. And that is what I would expect.
    >
    > However, the *exact* same setup on a different server gives me a result of
    > 'FALSE' properly. The other server has php 4.3.3 on it - the one giving the
    > improper response has php 4.1.2.
    >
    > Could this be the issue?
    I've never had an issue with this since php 3.01b or was that
    3.11b.. i always get those two confused :)

    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  2. Similar Questions and Discussions

    1. Fonts are there, then they're not. Bizarre.
      I am using InDesign CS on a pc. I use a limited number of fonts to layout our monthly newsletter. I installed the fonts I needed and they were...
    2. 5.80, OS X, bizarre FTP weirdness
      I am running Mac OS X 10.2.7 and recently upgraded from 5.6.1 to 5.8.0 following the guidance at...
    3. Bizarre SQl, if issue....
      Hey, I've got a weird issue. I have some code, an MySQL statement, that returns an empty set, like this: $person = mysql_query("Some Statement...
    4. Bizarre HD Problem
      OS: Win98/Mandrake 9.1 I just installed a new 80GB Maxtor HD (6Y080L0) and, while my BIOS sees it and it shows up in dmesg as 'hdd', a) It...
    5. Bizarre IE6 CSS error
      Hi all, I have the weirdest thing going on... it's hard even to describe, but bascically, IE6 seems to interpret differently the margins/padding...
  3. #22

    Default RE: [PHP] Bizarre SQl, if issue....

    > -----Original Message-----
    > From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
    > Sent: Tuesday, July 29, 2003 2:48 PM
    > To: Mike At Spy; [email]php-general@lists.php.net[/email]
    > Subject: RE: [PHP] Bizarre SQl, if issue....
    >
    >
    > [snip]
    > I did! Look at this again:
    >
    > $which_person = mysql_query("SELECT ID FROM tblItems WHERE number =
    > $place");
    >
    > $vthere = mysql_num_rows($which_person);
    >
    > if ($vthere == '0') { True } else { False }
    >
    > Yet it still returns as if this is FALSE (i.e. it executes the else {}.
    > :\
    > [/snip]
    >
    > try ....
    >
    > if ($vthere == 0) { True } else { False }

    Same result (actually, that was the first statement I tried). :\

    -Mike


    Mike At Spy Guest

  4. #23

    Default RE: [PHP] Bizarre SQl, if issue....

    [snip]
    if ($vthere == '0') { True } else { False }

    ....
    > if ($vthere == 0) { True } else { False }

    Same result (actually, that was the first statement I tried). :\
    [/snip]

    Then the query is failing.
    Jay Blanchard Guest

  5. #24

    Default RE: [PHP] Bizarre SQl, if issue....

    > This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
    > 19:46, lines prefixed by '>' were originally written by you.
    > > I did! Look at this again:
    > > $which_person = mysql_query("SELECT ID FROM tblItems WHERE
    > number =
    > > $place");
    > > $vthere = mysql_num_rows($which_person);
    > > if ($vthere == '0') { True } else { False }
    > > Yet it still returns as if this is FALSE (i.e. it executes the
    > else
    > > {}. :
    >
    > As long as your query is returning 0 rows that code should work ok,
    > but it is incorrect for correctness,
    > if ($vthere == '0')
    > should be
    > if ($vthere == 0)
    > As $vthere will contain an integer, not a string, but as you are
    > using the == comparison operator instead of === PHP should
    > convert them both to the same type before comparing.
    >
    > Can we see the snippet of the actual code that you are using?


    Actually, what you see is *exactly* the code being used. Nothing has changed
    about it. And whether the variable is regarded as a string or a number, it
    gives me the same stupid issue. Not recognizing it as a True statement. :\

    Is there any way possible that this could be the client's server? I had to
    beg to get 'em to recompile to 4.1.2 from 4.0.3. There are using a version
    of Linux I don't recognize (it isn't redhat or mandrake), but it looks like
    their kernel is up to date.

    On my redhat server (with php 4.3.3), the same code responds properly (i.e.
    that $vthere ==0 is true).

    :\

    -Mike


    Mike At Spy Guest

  6. #25

    Default RE: [PHP] Bizarre SQl, if issue....

    > [snip]
    > if ($vthere == '0') { True } else { False }
    >
    > ....
    >
    > > if ($vthere == 0) { True } else { False }
    >
    >
    > Same result (actually, that was the first statement I tried). :\
    > [/snip]
    >
    > Then the query is failing.
    But the query returns no errors - both on my code I use to test errors and
    the one you sent to me! :\

    And when I plug values into the query at command line - values that would
    return an empty set, it executes and returns an empty set.

    :)

    Thanks,

    -Mike


    Mike At Spy Guest

  7. #26

    Default RE: [PHP] Bizarre SQl, if issue....

    [snip]
    And when I plug values into the query at command line - values that
    would
    return an empty set, it executes and returns an empty set.
    [/snip]

    If the query is returning an empty set the value of
    mysql_num_rows($person) == 0

    so

    $person = mysql_query("The Query");
    $thecount = mysql_num_rows($person);
    echo "$thecount \n";

    And tell us what $thecount is...
    Jay Blanchard Guest

  8. #27

    Default RE: [PHP] Bizarre SQl, if issue....


    Returns 0 (zero).

    -Mike

    > -----Original Message-----
    > From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
    > Sent: Tuesday, July 29, 2003 3:05 PM
    > To: Mike At Spy; [email]php-general@lists.php.net[/email]
    > Subject: RE: [PHP] Bizarre SQl, if issue....
    >
    >
    > [snip]
    > And when I plug values into the query at command line - values that
    > would
    > return an empty set, it executes and returns an empty set.
    > [/snip]
    >
    > If the query is returning an empty set the value of
    > mysql_num_rows($person) == 0
    >
    > so
    >
    > $person = mysql_query("The Query");
    > $thecount = mysql_num_rows($person);
    > echo "$thecount \n";
    >
    > And tell us what $thecount is...
    >
    >
    Mike At Spy Guest

  9. #28

    Default RE: [PHP] Bizarre SQl, if issue....

    [snip]
    But that is my point - and I think we are going in circles now. It just
    doesn't do that. It returns 4 (as per your example). :\
    [/snip]

    Then something else is wrong Mike....very, very wrong.
    Jay Blanchard Guest

  10. #29

    Default RE: [PHP] Bizarre SQl, if issue....

    > [snip]
    > > $person = mysql_query("The Query");
    > > $thecount = mysql_num_rows($person);
    > > echo "$thecount \n";
    > >
    > > And tell us what $thecount is...
    >
    > Returns 0 (zero).
    > [/snip]
    >
    > Then
    > if($thecount == 0){
    > $whatever = 1;
    > } else {
    > $whatever = 4;
    > }
    >
    > $whatever should be 1
    But that is my point - and I think we are going in circles now. It just
    doesn't do that. It returns 4 (as per your example). :\

    -Mike



    Mike At Spy Guest

  11. #30

    Default Re: [PHP] Bizarre SQl, if issue....

    * Thus wrote Mike At Spy (spycobalt@spyproductions.com):
    Hey mike,
    >
    > > > $vthere = mysql_num_rows($which_person);
    > > > if ($vthere == '0') { True } else { False }
    >
    > Actually, what you see is *exactly* the code being used. Nothing has changed
    > about it. And whether the variable is regarded as a string or a number, it
    > gives me the same stupid issue. Not recognizing it as a True statement. :\
    Have you tried just testing the value of $vthere:
    if (!$vthere) { we dont have data } else { we have data }

    I've been using this method since really early versions of php and
    havn't had any problems with this method. Unless there was some
    excplicite bug with version 4.1.2, I may have skipped that version
    upgrade.
    >
    > Is there any way possible that this could be the client's server? I had to
    > beg to get 'em to recompile to 4.1.2 from 4.0.3. There are using a version
    > of Linux I don't recognize (it isn't redhat or mandrake), but it looks like
    > their kernel is up to date.
    Really they should at least stay current. I would insist they
    upgrade or remove php from their plan (argghh.)


    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  12. #31

    Default Re: [PHP] Bizarre SQl, if issue....

    Hello,

    This is a reply to an e-mail that you wrote on Tue, 29 Jul 2003 at
    19:59, lines prefixed by '>' were originally written by you.
    > Actually, what you see is *exactly* the code being used. Nothing
    has
    > changed
    > about it.
    No. It is not the code you are using.
    if ($vthere == 0) { True } else { False }
    would give a parse error.
    > Is there any way possible that this could be the client's server?
    I
    > had to
    > beg to get 'em to recompile to 4.1.2 from 4.0.3. There are using
    a
    > version
    > of Linux I don't recognize (it isn't redhat or mandrake), but it
    looks
    > like
    > their kernel is up to date.
    IMO, if you want to find out what is wrong you need to stop looking
    for things out of your control that could be breaking it. Chances
    are PHP is doing exactly as it is documented to do, no matter what
    PHP version, linux distro, kernel version or anything else in use.
    Follow your code through exactly as it would be when it is
    interpreted and be on the lookout for your mistake, not your excuse
    and you will find the error in your code!

    Right now though I think everyone is very confused about your problem
    so if you need more help from the group I would reccomend a new post,
    a code extract, what you expect to happen and what is actually
    happening.

    HTH,

    David.


    --
    phpmachine :: The quick and easy to use service providing you with
    professionally developed PHP scripts :: [url]http://www.phpmachine.com/[/url]

    Professional Web Development by David Nicholson
    [url]http://www.djnicholson.com/[/url]

    QuizSender.com - How well do your friends actually know you?
    [url]http://www.quizsender.com/[/url]
    (developed entirely in PHP)
    David Nicholson Guest

Posting Permissions

  • You may not post new threads
  • You may 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