Re: Help...
| From: | (Philip Hallstrom) | Date: | Fri, 02 Jun 2000 21:48:17 +0000 |
| Subject: | Re: Help... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-183@lists.php.net to get a copy of this message | ||
With what you're doing below PHP doesn't care whether it's a string or
an integer... it will treat it like a string when *you* treat it like a
string (ie. $x = $foo . "string";) and a number (assuming $foo contains
a valid number) when you do something like $x = $foo + 5;
What happens (error wise) if you do:
<?php
$db = ODBC_Connect("dive", "", "");
$res = ODBC_Exec($db, "SELECT *
FROM tblDiveData
WHERE DiveDepth >= 100");
?>
Instead of "$foo" put a valid number in there. That way you can
elimanate the possibility that $foo is causing the problem...
-philip
In article <20000602193041.24566.qmail@web2103.mail.yahoo.com>,
Tim Hulen <thulen@yahoo.com> wrote:
>Thanks for the thoughts. $foo is coming from an input
>form, were the user can input the depth (20-130).
>I was using this example for Dive Location (Hawaii,
>Honduras) and it would query the database
>appropriately.
>I'm using Access 2000 through an ODBC connection so
>I'm using the appropriate odbc functions. I thought
>by removing the quotes PHP would consider it an
>integer value. Does it matter how the input form
>handles it?
>?>
><form>
><form method=post action='qrydb.php3'>
><input type='text' name='foo'>
><input type='submit' name='submit' value='Search'>
></form>
><?
>Thanks for the help and info,
>Tim
>--- Carroll Barrett <cbarrett@inalt.com> wrote:
>> Tim,
>>
>> A couple of thoughts:
>>
>> 1) Your error message says 'DiveDepth =', but your
>> SQL statement says
>> 'DiveDepth >='.
>> Does your database support the '>=' operator?
>>
>> 2) Is $foo empty?
>>
>> Carroll Barrett
>>
>> -----Original Message-----
>> From: Tim Hulen <thulen@yahoo.com>
>> To: php-db@lists.php.net <php-db@lists.php.net>
>> Date: Thursday, June 01, 2000 7:39 PM
>> Subject: Re: [PHP-DB] Help...
>>
>>
>> >That is what I thought, but I get this error>?
>> >
>> >Warning: SQL error: [Microsoft][ODBC Microsoft
>> Access
>> >Driver] Syntax error (missing operator) in query
>> >expression 'DiveDepth ='., SQL state 37000 in
>> >SQLExecDirect in
>> >C:WEBSHAREWWWROOTphpdivedepthq.php on line 26
>> >
>> >
>> >--- Matt McClanahan <cardinal@dodds.net> wrote:
>> >> On Thu, 1 Jun 2000, Tim Hulen wrote:
>> >>
>> >> > I'm new to PHP and trying various test to
>> >> demonstrate
>> >> > to other the power of PHP. I also need to find
>> a
>> >> book
>> >> > that has some good documentation for reference
>> >> > especially when dealing with ODBC databases.
>> >> >
>> >> > I this example how do I pass foo to my query as
>> an
>> >> > integer instead of a string, do I can use the
>> <,>
>> >> as
>> >> > part of the where statement.
>> >> >
>> >> > <?php
>> >> > $db = ODBC_Connect("dive", "", "");
>> >> > $res = ODBC_Exec($db, "SELECT * FROM
>> >> tblDiveData
>> >> > WHERE DiveDepth >= '$foo'");
>> >>
>> >> I think if you just take the quotes off of $foo,
>> >> then SQL will consider it
>> >> an integer.
>> >>
>> >> E.g, $res = ODBC_Exec($db, "SELECT * FROM
>> >> tblDiveData WHWERE DiveDepth >=
>> >> $foo");
>> >>
>> >> Matt