Re: Strange result returned from Oracle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks!

I am still puzzled as to why it should return that value though :-/

Mikey
----- Original Message ----- 
From: "Francesco" <francesco.marsan@xxxxxxx>
Newsgroups: php.windows
To: <php-windows@xxxxxxxxxxxxx>
Sent: Wednesday, September 22, 2004 2:17 PM
Subject: Re: Strange result returned from Oracle


> Mikey,
> I would put the if condition (or a while loop, if you are retrieving more
> than 1 row) around the ocifetchinto, and not after that, as in your code.
> Here is how I would write it (off my head, not tested):
>
> $sql = "SELECT \"irpUser\" FROM tblUsers WHERE
> \"swmEmail\"='{$_POST['swmEmail']}'";
> $sth = ociparse ($conn, $sql) or die ("Couldn't parse SQL: $sql<br>\n");
> ociexecute ($sth)  or die ("Couldn't execute SQL: $sql<br>\n");
> if (ocifetchinto ($sth, $usr, OCI_ASSOC)) {
>   // Do stuff here with $usr['irpUser']
> }
> else {
>    // No rows returned here
> }
>
> HTH
> Francesco
> --------------------------
> "Mikey" <mikey@xxxxxxxxxxxxxxxxxxx> wrote:
> >I have
> > the following code:
> >
> > $sql = "SELECT \"irpUser\" FROM tblUsers WHERE
> > \"swmEmail\"='{$_POST['swmEmail']}'";
> > $sth = ociparse ($conn, $sql)
> >  or die ("Couldn't parse SQL: $sql<br>\n");
> > ociexecute ($sth)
> >  or die ("Couldn't execute SQL: $sql<br>\n");
> > ocifetchinto ($sth, $usr, OCI_ASSOC);
> > if ($usr['irpUser'] == "")
> > {
> >   // Do stuff here
> > }
> > else
> > {
> >   //Something else
> > }
> >
> > Now, when the query brings back a record everything works fine, but when
> the
> > query returns nothing (i.e. brand new user) it still goes to the else
> branch
> > of the code.  I have echo'ed $usr to the screen and it contains the
string
> > "SYSTEM".  Now as far as my code goes I don;t think this is too much of
a
> > problem as I can just check for this string (normal values are integer),
> but
> > I can find no reference to this behaviour in the docs and would like to
> know
> > what is causing this return value.  Any ideas?
> >
> > Mikey
> > ---
> > Developer - Radius Design Ltd.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux