[PHP-DB] IBM DB2 and php

2003-10-19 Thread Gerard Samuel
Maybe in early August, I got my code to work with DB2 8.1.3 via ODBC 
after a bit of teeth pulling.
I played with it for about 2-3 weeks, and it seemed ok (slow but ok).
Earlier this past week, I was modifying the DB drivers for my script,
and now, DB2 refuses to cooperate.
I don't remember changing any php.ini settings so Im confused as to why 
it doesn't work now.
Im testing on w2k, php 4.3.3, db2 8.1.3
The problem revolves around field lengths being too long, because, as 
soon as I select
a text field, the query fails, when trying to retrieve specific result rows.
If anyone can shed any light on this, I would greatly appreciate it.
Thanks

php.ini settings

; Handling of LONG fields. Returns number of bytes to variables. 0 means
; passthru.
odbc.defaultlrl = 4096
; Handling of binary data. 0 means passthru, 1 return as is, 2 convert 
to char.
; See the documentation on odbc_binmode and odbc_longreadlen for an 
explanation
; of uodbc.defaultlrl and uodbc.defaultbinmode
odbc.defaultbinmode = 1


example script

|?php
||// contains db connection stuff|
|include('include.php');
// body is a text field
$sql = 'select id, user_id, name, time, body, ip from NULLID.guestbook for read only';
$result = odbc_exec($db-_connection_id, $sql);
odbc_longreadlen($result, 0);
odbc_binmode($result, 0);
// Trying to retrieve 2nd row out of 6 rows returns false when
// the query contains a text field
var_dump(odbc_fetch_array($result, 2));
?|

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


Re: [PHP-DB] IBM DB2 and php

2003-10-19 Thread Gerard Samuel
Gerard Samuel wrote:

example script

|?php
||// contains db connection stuff|
|include('include.php');
// body is a text field
$sql = 'select id, user_id, name, time, body, ip from NULLID.guestbook 
for read only';
$result = odbc_exec($db-_connection_id, $sql);

odbc_longreadlen($result, 0);
odbc_binmode($result, 0);
// Trying to retrieve 2nd row out of 6 rows returns false when
// the query contains a text field
var_dump(odbc_fetch_array($result, 2));
?| 
Sorry, bad copy/paste

?php
// contains db connection stuff
|include('mainfile.php');
|// body is a text field
|$sql = 'select id, user_id, name, time, body, ip from NULLID.mpn_guestbook for read 
only';
$result = odbc_exec($mpn2_db-_db_connection_id, $sql);
odbc_longreadlen($result, 0);
odbc_binmode($result, 0);
|// Trying to retrieve 2nd row out of 6 rows returns false when
// the query contains a text field
|var_dump(odbc_fetch_array($result, 2));
?
|
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Ranges query gone wild

2003-10-19 Thread Boaz Amit
Hi.

I have a MySQL table where a product price ranges are set according to
quantities.
For instance for a certain product you'd have (besides id columns):

range_begin |   range_end  |  range_price
0 |  35   |   1.5
36   |  70   |   2
71   |  -  |   3

Where '-' is always the character that means '..and above' and closes the
entire range field. So in the above example a quantity of 71 and above has a
price tag - $3.

I have limited success with writing the simple query that when given a
quantity returns its correct price range. This is what I came up with:

SELECT `range_price` FROM `price_ranges` WHERE `product_id` = '$product_id'
 `size_id` = '$size_id'  ((`range_begin` = '$quantity'  `range_end` =
'-') || (`range_begin` = '$quantity'  `range_end` = '$quantity'));

It partially works. But given the above example, it'll correctly return for
a quantity of 71-79 the price of 3, but for anything above that it'll return
the wrong price - 1.5. It works fine if I remove the second part of the OR
construct.
Also it returns nothing for the quantities of 4-9 (?!).

I've tested this on my machine (MySQL ver: 3.23.54) and on the customer's
server
(ver: 4.0.14), and got the same results. Obviously I'm not getting the
logical scheme right. If anyone can point out the problem or suggest a
better way to write the query I'd appreciate it.

Thank you, Boaz Amit

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



[PHP-DB] Re: Ranges query gone wild

2003-10-19 Thread Hugh Bothwell
Boaz Amit [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I have a MySQL table where a product price ranges are
 set according to quantities.
 For instance for a certain product you'd have (besides id columns):

 range_begin |   range_end  |  range_price
 0 |  35   |   1.5
 36   |  70   |   2
 71   |  -  |   3

 Where '-' is always the character that means '..and above' and closes the
 entire range field. So in the above example a quantity of 71 and above has
a
 price tag - $3.

First danger signal:  duplication of data (or, storage of
data that should be a result of calculation).
For a given product, range_end = (range+1)_begin - 1

Second danger signal:  needing a 'bad data' type.
In some cases, may be necessary to have a separate
valid-data field, but better to simply not allow bad
data if at all possible.


Instead, remove the redundant field:

range_begin   |   range_price
   0 |1.5
   36   |2
   71   |3

and the query becomes

SELECT range_price
  FROM price_ranges
  WHERE
 product_id = '$product_id'
 size_id = '$size_id'
 range_begin = '$quantity'
  ORDER BY range_begin DESC
  LIMIT 1


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+

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



[PHP-DB] Re: Ranges query gone wild

2003-10-19 Thread Hugh Bothwell
(repost: first try bounced)

Boaz Amit [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 I have a MySQL table where a product price ranges are
 set according to quantities.
 For instance for a certain product you'd have (besides id columns):

 range_begin |   range_end  |  range_price
 0 |  35   |   1.5
 36   |  70   |   2
 71   |  -  |   3

 Where '-' is always the character that means '..and above' and closes the
 entire range field. So in the above example a quantity of 71 and above has
a
 price tag - $3.

First danger signal:  duplication of data (or, storage of
data that should be a result of calculation).
For a given product, range_end = (range+1)_begin - 1

Second danger signal:  needing a 'bad data' type.
In some cases, may be necessary to have a separate
valid-data field, but better to simply not allow bad
data if at all possible.


Instead, remove the redundant field:

range_begin   |   range_price
   0 |1.5
   36   |2
   71   |3

and the query becomes

SELECT range_price
  FROM price_ranges
  WHERE
 product_id = '$product_id'
 size_id = '$size_id'
 range_begin = '$quantity'
  ORDER BY range_begin DESC
  LIMIT 1


--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L+$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+

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



[PHP-DB] PostgreSQL, Triggers

2003-10-19 Thread Ling
Hello there.
Can anybody help me with Postgresql triggers?
what I need is a trigger which inrements value in field total_rows.rows
if I insert new row in table zzz...

CAREATE TABLE zzz (
...
...
);
CREATE TABLE total_rows (
table_name VARCHAR(32),
total_rows BIGINT,
CONSTRAINT pk_total_rows PRIMARY KEY(table_name, total_rows)
);

Thanks a lots
regars
Ling.

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



[PHP-DB] PHP/MySQL Help

2003-10-19 Thread conbud

From: Conbud [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: PHP/MySQL/Server not working
Date: Friday, October 17, 2003 6:17 PM

Hey, just a quick question, I have a form that users can fill out to join a
certain group, we can then view that info from an admin page that requires
logging in. When a user fills out the form I get an email letting me know
that the form was submitted with the users info as well. Here recently, I've
been getting that info but their info isn't being saved into the database
for somereason, anyone have any idea why ? I have filled out the form at
least 15-25 times using different info and everyone of them worked for me. I
even filled out the form using different special characters and still with
no problems, I am using stripslashes on the form data, but I don't think
that could keep the info from being saved to the database, it only does this
periodically. Could this be due to a slow server ? or is there some sort of
special character that could conflict with my PHP or with the MySQL syntax ?
I just have no clue now. Any thoughts are appreciated.

Thanks
ConbuD

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



[PHP-DB] Re: PHP/MySQL Help

2003-10-19 Thread conbud
Hey, Also the webhost only allows us a direct database connection
using phpMyadmin, I did notice that on the table that stores the info, it
keep getting an error after someone is posting the form. The error says
something about Overhead: 275 bytes, Is this just an MySQL limitation that
is set by the webhost ? and this overhead you think that would keep the info
from being entered into the database. To get the error to go away I have to
optimize the table.

ConbuD

Conbud [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 From: Conbud [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: PHP/MySQL/Server not working
 Date: Friday, October 17, 2003 6:17 PM

 Hey, just a quick question, I have a form that users can fill out to join
a
 certain group, we can then view that info from an admin page that requires
 logging in. When a user fills out the form I get an email letting me know
 that the form was submitted with the users info as well. Here recently,
I've
 been getting that info but their info isn't being saved into the database
 for somereason, anyone have any idea why ? I have filled out the form at
 least 15-25 times using different info and everyone of them worked for me.
I
 even filled out the form using different special characters and still with
 no problems, I am using stripslashes on the form data, but I don't think
 that could keep the info from being saved to the database, it only does
this
 periodically. Could this be due to a slow server ? or is there some sort
of
 special character that could conflict with my PHP or with the MySQL syntax
?
 I just have no clue now. Any thoughts are appreciated.

 Thanks
 ConbuD

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



Re: [PHP-DB] $_POST in MySQL query issue...

2003-10-19 Thread Adam Reiswig
A couple of days ago I placed a post regarding using the $_POST[] 
variable in an insert sql query.  Both

$sql=insert into $table set Name = '.$_POST['elementName'].';
  and
$sql=insert into $table set Name = '{$_POST['elementName']}';
worked perfectly.  Thanks to everyone for your help.  My question now is 
regarding the curly brackets in the 2nd example.  Can anyone describe 
why using the curly brackets works and/or how php processes them.  I 
have read quite a bit about php and never come accross thier use in this 
way.  Thanks again.

-Adam Reiswig

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


[PHP-DB] $_POST in MySQL query issue...

2003-10-19 Thread Adam Reiswig
A couple of days ago I placed a post regarding using the $_POST[]
variable in an insert sql query.  Both
$sql=insert into $table set Name = '.$_POST['elementName'].';
  and
$sql=insert into $table set Name = '{$_POST['elementName']}';
worked perfectly.  Thanks to everyone for your help.  My question now is
regarding the curly brackets in the 2nd example.  Can anyone describe
why using the curly brackets works and/or how php processes them.  I
have read quite a bit about php and never come accross thier use in this
way.  Thanks again.
-Adam Reiswig

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


Re: [PHP-DB] $_POST in MySQL query issue...

2003-10-19 Thread John W. Holmes
Adam Reiswig wrote:

My question now is
regarding the curly brackets in the 2nd example.  Can anyone describe
why using the curly brackets works and/or how php processes them.  I
have read quite a bit about php and never come accross thier use in this
way.  Thanks again.
http://us2.php.net/manual/en/language.types.string.php#language.types.string.parsing

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP-DB] $_POST in MySQL query issue...

2003-10-19 Thread Lee Doolan
 Adam == Adam Reiswig [EMAIL PROTECTED] writes:

Adam A couple of days ago I placed a post regarding using the
Adam $_POST[] variable in an insert sql query.  Both

Adam $sql=insert into $table set Name =
Adam '.$_POST['elementName'].'; and $sql=insert into $table
Adam set Name = '{$_POST['elementName']}';

The only remark which I would make here is to beware of SQL injection.
Here are a couple of good resources to explain what an SQL injection
attack is and what you should do to protect your code:
http://www.securiteam.com/securityreviews/5DP0N1P76E.html
http://www.sitepoint.com/article/794


-- 
no toll on the internet; there are paths of many kinds;
whoever passes this portal will travel freely in the world

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



Re: [PHP-DB] PostgreSQL, Triggers

2003-10-19 Thread Martin Marques
El Dom 19 Oct 2003 13:54, Ling escribió:
 Hello there.
 Can anybody help me with Postgresql triggers?
 what I need is a trigger which inrements value in field total_rows.rows
 if I insert new row in table zzz...

 CAREATE TABLE zzz (
 ...
 ...
 );
 CREATE TABLE total_rows (
 table_name VARCHAR(32),
 total_rows BIGINT,
 CONSTRAINT pk_total_rows PRIMARY KEY(table_name, total_rows)
 );

A rule would be much easier:

CREATE RULE rule_name AS ON INSERT TO zzz DO 
Write an update of total_rows query here;


-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telemática
   Universidad Nacional
del Litoral
-

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



Re: [PHP-DB] Variables not working within Functions

2003-10-19 Thread Colin Kettenacker
Or pass the variable $username as an argument into your function:

function LoginSystem($username) {
// your function code
}

LoginSystem($username);

ck

-- 
Cheap Domain Registration | Web Hosting | Email Packages | + more
Fantastic prices -- Even better service.
http://www.hosttohost.net


Chris Wanstrath [EMAIL PROTECTED] on 10/15/03 7:57 PM wrote:

 You are using a variable outside of the function's scope.
 In the function, do this:
 global $username;
 
 Visit www.php.net/man to get a better understanding of globals and
 scope.
 
 On Wed, 2003-10-15 at 22:10, Adam Symonds wrote:
 Hi,
 I am starting to us functions with my work but I am having troubles
 With the variables in the functions..
 
 If I have the following function called from my page it will work but the
 variable wont
 ($username)
 but if I put this code straight on the page then it works fine..
 
 Any reason for the variable not to work in the function but in straight
 coding?
 Thanx
 
 
 
 Sample Function Below:
 
 ==
 function LoginSystem()
 {
 echo div align=right;
 if ( !isset( $_SESSION['login'] ) ) {
 
 echo form action=../Users/Login.php method=post;
 echo font size=1Username: /fontinput name=user type=text
 size=10nbsp;font size=1Password: /fontinput name=pass type=password
 size=10nbsp;input type=submit value=GObr;
 echo a href=../Register.phpfont size=1Not A Member
 Yet?/font/font/anbsp;;
 echo /form;
 
 } else {
 echo font size=1Welcome $username nbsp;nbsp;nbsp;a
 href=../Users/Logout.phpfont
 size=1Logout/anbsp;nbsp;nbsp;/font/fontbrbr;
 }
 echo /div;
 }

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



[PHP-DB] WHERE statement used multiple times.

2003-10-19 Thread JeRRy
 
 Hi,
 
 If I was to want to use the WHERE statement multiple
 times (more than once) how do I seperate each WHERE
 statement?
 
 Would it be with a ',' (coma) or a ' ' (space) or
 what?  Or not possible to have multiple WHERE's in
 the
 one query?
 
 I need 2 tables checked before executing the
 results. 
 So that is why I need 2 WHERE statements done.  
 
 Thanks!
 
 http://personals.yahoo.com.au - Yahoo! Personals
 New people, new possibilities. FREE for a limited
time. 

http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.

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



Re: [PHP-DB] WHERE statement used multiple times.

2003-10-19 Thread Chris Wanstrath
On Mon, 2003-10-20 at 00:56, JeRRy wrote:
   Hi,
  
  If I was to want to use the WHERE statement multiple
  times (more than once) how do I seperate each WHERE
  statement?
  
  Would it be with a ',' (coma) or a ' ' (space) or
  what?  Or not possible to have multiple WHERE's in
  the
  one query?
  
  I need 2 tables checked before executing the
  results. 
  So that is why I need 2 WHERE statements done.  
  
  Thanks!
  
  http://personals.yahoo.com.au - Yahoo! Personals
  New people, new possibilities. FREE for a limited
 time. 

You can put together WHERE statements with an AND or an OR.  For
instance, SELECT id FROM users WHERE id='2' OR id='3'

You know, if you had a few suspicions about this sort of thing you could
always give it a spin in a Query.  Worst case scenario is you will get
an error.

- Chris

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



[PHP-DB] second time: problem with LDAP support

2003-10-19 Thread zxx10
Sorry for resending the same question. Actually,
I sent the following message a few days before.
However, it seems that no one has the experience
on LDAP. It's a headache for me. Hope this time
some experts can take a look at the question.

I appreciate your kind helps!

***
Dear friends:

 I have a problem of installation of php.

 I'm using Linux 7.3. I have installed 
 openldap2.1.22 successfully.

 Now I'm compiling php with the following
 command:

 ./configure --with-apache2=/usr/local/apache2 \
 --with-mysql=/usr/local/mysql \
 --with-ldap=/usr/local/ldap

 The configuration is past. However, when I
 type make, the following error occured:
 gcc: sapi/cli/php_cli.o: No such file or directory
 gcc: sapi/cli/getopt.o:  No such file or directory
 make: ***[sapi/cli/php] Error 1

 Any ideas?

 Many thanks in advance.

 Zhan Xu
 EECS Department
 Case Western Reserve University
 Email: [EMAIL PROTECTED]

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