Re: [PHP-DB] Corn job anomaly

2016-09-20 Thread Peter Beckman
to run as a different user. If the issue is mysql
access, you do that just the way you would in a [web]server parsed
php file.

The script is whatever you put on the crontab line.

The script you reference from the crontab entry can be a shell script
that does some setup, and then calls your php script.  Your php
script can have include files (e.g., for mysql connection setup) just
as you might have in a [web]server parsed php file.





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



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




---
Peter Beckman  Internet Guy
beck...@angryox.com http://www.angryox.com/
---

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



Re: [PHP-DB] Re: Database Problems

2012-06-25 Thread Peter Beckman

On Mon, 25 Jun 2012, B. Aerts wrote:


On 17/06/12 21:06, Ethan Rosenberg wrote:

Dear List -

I have a database:

+-+
| Tables_in_hospital2 |
+-+
| Intake3 |
| Visit3 |
+-+


 Hey Ethan --

 Remember that your posts are archived likely forever, and using dummy data
 like Bongish and being critical of people's weight probably isn't going
 to help you when you decide to seek a job somewhere.

 Also, for people replying, before offering advice about MySQL on a PHP
 list, it is good practice to actually run your queries to verify your
 suggestions.  Most of the replies thus far have been conjecture, with only
 one or two reasonable data-backed voices.

 Those voices asked: What are you doing with $result? How you answer is
 important.  If you are simply printing it with hopes that $result contains
 data, the suggestion to RTFM is vital, as that would be wrong.

 Those voices also stated 'where 1' just evaluates to true.  They are
 correct and proven here (42 intentional :-) ):

mysql select count(*) from numbers where 1=1 and num like '1212%';
+--+
| count(*) |
+--+
|   42 |
+--+
1 row in set (0.26 sec)

mysql select count(*) from numbers where 1 and num like '1212%';
+--+
| count(*) |
+--+
|   42 |
+--+
1 row in set (0.02 sec)

mysql select count(*) from numbers where num like '1212%';
+--+
| count(*) |
+--+
|   42 |
+--+
1 row in set (0.02 sec)

 So Ethan, if your query works on the command line, but not in your code,
 where do you think the issue might exist?

 http://us3.php.net/manual/en/mysqli.query.php

Return Values

Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or
EXPLAIN queries mysqli_query() will return a mysqli_result object. For
other successful queries mysqli_query() will return TRUE.

 Granted, the PHP manual doesn't include *how* to loop through return data.

 http://us3.php.net/manual/en/class.mysqli-result.php

Ethan, your question was: why does this work on the command line, and not 
through PHP.


The remarks by other posters still stand - you don't show anything that leads 
us to discriminate wether the fault lies in the query, in the API's or in the 
code.


If you're not going to show it, maybe try the following 2 tips :
1) try to modify the query: SELECT . . . WHERE 1=1 ;  : this formulation 
removes any doubt wether it is a filtering statement, or a result limiting 
statement


2) see if  SELECT . . . WHERE 2 or  SELECT . . . WHERE 3  yields 
respecively 2 or 3 result rows. If not, the problem is NOT with the API's.


 I'll save you some time, it's not the where 1 part of the query:

mysql select count(*) from numbers where 3 and num like '1212%';
+--+
| count(*) |
+--+
|   42 |
+--+

Beckman
---
Peter Beckman  Internet Guy
beck...@angryox.com http://www.angryox.com/
---

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



Re: [PHP-DB] Multiple Database Connection Using Prepard Statements

2012-05-19 Thread Peter Lind
On 19 May 2012 20:36, Ron Piggott ron.pigg...@actsministries.org wrote:

 How do I connect to multiple mySQL databases using Prepared Statements ?

 I have the syntax

 ===
 $dsh = 'mysql:host=localhost;dbname='.$database3;
 $dbh = new PDO($dsh, $username, $password);
 ===

 I want to connect to $database1 without loosing my $database3 connection

 Thoughts?  Comments?


Create a new PDO object with the connection details you need?

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] Storing multiple items in one MySQL field?

2012-01-11 Thread Peter Lind
*snip*


 How does set() know the difference between say
 the first row (1) + the fifth row (5) and the second row (2) + fouth row (4)
 in the bit set? The sum of both are the same.
 I am sure I am congfusing something.


Ummm ... if you're asking how set figures out how bitmasks differ,
then yes, you're very confused. It's a bitmask, summing plays no role.
Rest assured that set will know the difference between different kinds
of content in the column.

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] Storing multiple items in one MySQL field?

2012-01-10 Thread Peter Lind
On Jan 11, 2012 7:13 AM, Karl DeSaulniers k...@designdrumm.com wrote:


 On Jan 10, 2012, at 10:49 PM, Karl DeSaulniers wrote:


 On Jan 10, 2012, at 9:30 AM, B. Aerts wrote:

 On 08/01/12 23:35, Karl DeSaulniers wrote:


 On Jan 8, 2012, at 10:36 AM, Bastien wrote:



 On 2012-01-08, at 7:27 AM, Niel Archer n...@chance.now wrote:


 --
 Niel Archer
 niel.archer (at) blueyonder.co.uk

 Hello phpers and sqlheads,
 If you have a moment, I have a question.

 INTRO:
 I am trying to set up categories for a web site.
 Each item can belong to more than one category.

 IE: Mens, T-Shirts, Long Sleeve Shirts, etc.. etc..
 (Sorry no fancy box drawing)

 QUESTION:
 My question is what would the best way be to store this in one MySQL
 field and how would I read and write with PHP to that field?
 I have thought of enum() but not on the forefront of what that
 actually does and what it is best used for.
 I just know its a type of field that can have multiple items in it.
 Not sure if its what I need.

 REASON:
 I just want to be able to query the database with multiple category
 ID's and it check this field and report back if that category is
 present or if there are multiple present.
 Maybe return as a list or an array? I would like to stay away from
 creating multiple fields in my table for this.


 Have you considered separate tables? Store the categories in one
table
 and use a third to store the item and category combination, one row
per
 item,category combo. This is a common pattern to manage such
situations.

 NOTE:
 The categories are retrieved as a number FYI.

 Any help/code would be greatly appreciated.
 But a link does just fine for me.

 Best Regards,

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com

 Hope your all enjoying your 2012!



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


 Neil's solution is the best. Storing a comma separated list will
 involve using a LIKE search to find your categories. This will result
 in a full table scan and will be slow when your tables get bigger.
 Storing them in a join table as Neil suggested removes the need for a
 like search an will be faster

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


 Thanks guys for the responses. So.. what your saying if I understand
 correctly.
 Have the categories in one table all in separate fields.
 Than have a the products table. Than have a third table that stores say
 a product id
 and all the individual categories for that product in that table as
 separate fields associated with that product id?

 Am I close? Sounds like a good situation, but I didn't want to really
 create a new table.
 One product will probably have no more than 3 combinations of
 categories. So not sure it this is necessary.

 EG:

 Tshirts = 1
 Jackets = 2
 etc..

 Mens = 12
 Womens = 13

 So lets say I want to find all the Mens Tshirts.. I was wanting one
 field to hold the 1, 12

 hope that clarifies

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


 Hi Karl,

 if you don't want to do with the third-table-solution, how about an
assembler-style bit-wise OR of all categories ?

 constant TSHIRTS = 1 ;  // 2 to the 0th power
 constant JACKETS = 2 ;  // 2 to the 1st power
 constant MENS= 8 ;  // 2 to the 3rd power
 constant WOMENS  = 16 ; // 2 to the girl power :-)

 INSERT INTO TABLE t_myTable ( ID, categoryField)
 VALUES ( myNewId, TSHIRTS | MENS ) ;

 SELECT ID
 FROM t_myTable
 WHERE  ( categoryField  ( TSHIRTS | MENS ))  0 ;

 This assumes that your number of categories is not that big of course,
as you're limited to 64 bits/categories on a modern machine.

 Bert

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


 Hi Bert,
 Thanks for the response. I did consider that, but there may be more than
64 categories.
 So I am thinking that may not be best for my situation. I am actually at
the same point again, but
 this time with the colors. I have multiple colors for each tshirt.
 I dont want to put all the separate colors as their own fields and there
is an image associated with those colors too.
 I'd also like to not put those all in separate fields if I can.

 What's the best way to store multiple values that may change from time
to time?
 What kind of field?

 IE:
 ('red.png', 'green.png', 'blue.png')

 SET()
 enum()
 blob()
 varchar()

 ???
 TIA

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com


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



 I am thinking of limiting the colors to 10 for now (after all there are
only so many ways to die a shirt. =)
 and using a comma delimited list of abbreviated color names as a varchar
string.
 Then read out that string, explode on the commas and put in an array.

 `pd_color` varchar(39) CHARACTER SET utf8 NOT NULL DEFAULT

Re: [PHP-DB] foreign key

2011-08-09 Thread Peter Lind
On 9 August 2011 20:31, Chris Stinemetz chrisstinem...@gmail.com wrote:
 Okay. I am pretty new to mysql so this may seem like a ridiculous
 question to some people.

 I am trying to use a LEFT JOIN query, but the results I am finding
 unusual. For every record occurrence there is for the query, the
 results are duplicated by that amount.

 So if there are 3 records from the query results, then the output is 3
 times what I expect.. if that makes sense.

 From what I have researched so far. I believe I may need to add a
 foreign key to build the relations between the two tables.

 Based on the query can any tell me the correct way of adding the
 foreign key if ,in fact, that is what I need?

 I can provide table structures and information if necessary.

 The query is:

 $posts_sql = SELECT
 store_subject,
 store_comments,
 store_date,
 store_tptest,
 store_by,
 users.user_id,
 users.user_name,
 users.first_name,
 users.last_name
 FROM
 stores
 LEFT JOIN
 users
 ON
 stores.store_by = users.user_id
 WHERE
 stores.store_subject = ' . mysql_real_escape_string($_GET['id']).'
 ORDER BY
 stores.store_date DESC ;

 The query dump is:

 SELECT store_subject, store_comments, store_date, store_tptest,
 store_by, users.user_id, users.user_name, users.first_name,
 users.last_name FROM stores LEFT JOIN users ON stores.store_by =
 users.user_id WHERE stores.store_subject = 'Noland Park Plaza 3509 S.
 Noland Rd' ORDER BY stores.store_date DESC


Is users.user_id unique?

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] foreign key

2011-08-09 Thread Peter Lind
On 9 August 2011 20:49, Chris Stinemetz chrisstinem...@gmail.com wrote:

 Is users.user_id unique?


 yes it is.


What does your result look like? Hard to say what the problem is
without seeing the result.


-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] foreign key

2011-08-09 Thread Peter Lind
On 9 August 2011 21:23, Chris Stinemetz chrisstinem...@gmail.com wrote:


 
 
  What does your result look like? Hard to say what the problem is
  without seeing the result.
 

 I am echoing the query and printing the get array just for debugging 
 purposes, but below you can see how it is repeating its' self.

 Thank you

So you're saying that
SELECT stores.store_subject, stores.store_comments, stores.store_date,
stores.store_tptest, stores.store_by, users.user_id, users.user_name,
users.first_name, users.last_name FROM stores LEFT JOIN users ON
stores.store_by = users.user_id WHERE stores.store_subject = 'Bella
Roe 4980 Roe Blvd' ORDER BY stores.store_date DESC

returns

Chris Stinemetz 08-09-2011 02:08PM 600kbps-3.8mbps test
Chris Stinemetz 08-09-2011 02:08PM 600kbps-3.8mbps test
Chris Stinemetz 08-09-2011 02:07PM 0-250kbps test1
Chris Stinemetz 08-09-2011 02:07PM 0-250kbps test1

From the above, can't see where your problem is but something in your
join is obviously not unique - whether it's the first or second table.

--
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] Re: php-db foreign key

2011-08-09 Thread Peter Lind

 When I dump the query and run it in console I get the results I want. Not
 sure what I am doing wrong.

Your php code had more than one query running (one inside the other).
It's the outer query that runs twice, not the inner one returning
double the results

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] Re: php-db foreign key

2011-08-09 Thread Peter Lind
On 9 August 2011 22:25, Chris Stinemetz chrisstinem...@gmail.com wrote:

 Your php code had more than one query running (one inside the other).
 It's the outer query that runs twice, not the inner one returning
 double the results



 Thanks Peter,

 Do you have any suggestions on how to fix this?

 Thank you,

 Chris


Yes, debug your code and figure out why it's looping twice instead.
For instance, try the other query in the mysql console.


-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] Re: php-db foreign key

2011-08-09 Thread Peter Lind
On 9 August 2011 22:38, Chris Stinemetz chrisstinem...@gmail.com wrote:

 Yes, debug your code and figure out why it's looping twice instead.
 For instance, try the other query in the mysql console.


 Thank you! It was the first query. I put a LIMIT 1 on it and now it is
 working correctly. I appreciate your help!


You're fixing the symptom, not the problem. Your query was returning
multiple values because something is wrong with the query or your
data. If you don't correct it, the problem will likely just grow
bigger.


-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] Left Join

2011-08-07 Thread Peter Lind
Maybe it's just me, but I can't see anything that would work as
foreign key for you to join on - neither table seems to have a foreign
key

On 7 August 2011 21:53, Chris Stinemetz chrisstinem...@gmail.com wrote:
 I am tyring to build a query that will take the most recent
 stores.store_date column then join it with store_list.store_name where
 store_list.store_name and
 stores.store_subject match then return the most recent stores.store_date.
 I am guessing this will require some sort of join. I have been tyring to
 figure it
 out but have had no luck.
 Any help is greatly apprciated.
 Thank you.

 mysql select * from stores;
 +--+-++-+---+--+-+--
 ---+
 | store_id | store_subject   | store_type | store_date          | store_mar
 | store_by | store_tptest    | store_comment
 s          |
 +--+-++-+---+--+-+--
 ---+
 |       78 | Bella Roe       | corporate  | 2011-06-28 15:01:02 |         0
 |        1 |                 |
          |
 |       79 | Bella           | corporate  | 2011-08-06 08:48:26 |         0
 |        1 | 600kbps-3.8mbps | test
          |
 |       80 | Brittney~2120   | corporate  | 2011-08-06 08:48:50 |         1
 |        1 | 600kbps-3.8mbps | should post t
 o Wichita! |
 |       81 | Motor           | premier    | 2011-08-06 14:52:55 |         1
 |        1 | 600kbps-3.8mbps | test
          |
 |       82 | Liberty         | corporate  | 2011-08-06 14:54:41 |         0
 |        1 | 0-250kbps       | test
          |
 |       83 | Seneca~3165     | corporate  | 2011-08-06 14:58:47 |         0
 |        1 | 600kbps-3.8mbps | test
          |
 |       84 | Liberty         | corporate  | 2011-08-06 14:59:32 |         0
 |        1 | 400-600kbps     | test
          |
 |       85 | Brittney~2120   | corporate  | 2011-08-06 15:00:43 |         0
 |        1 | 600kbps-3.8mbps | test
          |
 |       86 | Liberty         | corporate  | 2011-08-06 15:01:11 |         0
 |        1 | 300-400kbps     | test
          |
 |       87 | Brittney~2120   | corporate  | 2011-08-06 15:11:06 |         0
 |        1 | 250-300kbps     | test
          |
 |       88 | Brittney~2120   | corporate  | 2011-08-06 15:23:53 |         1
 |        1 | 600kbps-3.8mbps | test
          |
 |       89 | Bella           | corporate  | 2011-08-06 15:31:49 |         0
 |        1 | 600kbps-3.8mbps | test
          |
 |       90 | Cleartalk~10221 | premier    | 2011-08-06 15:32:54 |         0
 |        1 | 250-300kbps     | test
          |
 |       91 | Chit            | premier    | 2011-08-06 15:33:50 |         1
 |        1 | 250-300kbps     | test
          |
 |       92 |                 |            | 2011-08-06 15:34:21 |         2
 |        1 | 300-400kbps     | test
          |
 |       93 | Bella           | corporate  | 2011-08-07 11:26:13 |         0
 |        1 | 600kbps-3.8mbps | test
          |
 +--+-++-+---+--+-+--
 ---+
 16 rows in set (0.00 sec)
 mysql

 mysql select * from store_list LIMIT 15;'
 ++---+++-+---+
 | id | market_prefix | store_name                             | store_type |
 market_name | id_market |
 ++---+++-+---+
 |  1 | MCI           | Bella Roe~4980 Roe Blvd                | Corporate  |
 Kansas City |         0 |
 |  2 | MCI           | Cleartalk~4635 Shawnee Dr              | Premier    |
 Kansas City |         0 |
 |  3 | MCI           | Cleartalk~3612 State Avenue            | Premier    |
 Kansas City |         0 |
 |  4 | MCI           | Endless Wireless~1620 Central Avenue   | Premier    |
 Kansas City |         0 |
 |  5 | MCI           | Get Wireless~840 Minnesota             | Premier    |
 Kansas City |         0 |
 |  6 | MCI           | Ring Ring Wireless~7559 State Avenue   | Premier    |
 Kansas City |         0 |
 |  7 | MCI           | Cleartalk~1212 Sante Fe                | Premier    |
 Kansas City |         0 |
 |  8 | MCI           | Cleartalk~10221 W 75th Street          | Premier    |
 Kansas City |         0 |
 |  9 | MCI           | Free Talk~10830 Shawnee Mission Pkwy   | Premier    |
 Kansas City |         0 |
 | 10 | MCI           | Loma Vista~8712 Blue Ridge Blvd        | Corporate  |
 Kansas City |         0 |
 | 11 | MCI           | Ring Ring Wireless~25 W. 39th Street   | Premier    |
 Kansas City |         0 |
 | 12 | MCI           | Ring Ring Wireless~3039 Prospect Ave   | Premier    |
 Kansas City |         0 |
 | 13 | MCI           | Ring Ring Wireless~1201 E Linwood Blvd | Premier    |
 Kansas City |         0 |
 | 14 | MCI           | Ring Ring 

Re: [PHP-DB] mysql_num_rows == 0

2011-05-30 Thread Peter Lind
On 30 May 2011 22:31, Nazish naz...@jhu.edu wrote:
 Hi all,

 I've run into a little barrier, and I'm wondering whether you have any
 insights. I'm entering values into a MySQL database. Before running the
 mysql_query, I'm checking if the value already exists (using mysql_num_rows
 == 0).  If the value already exists in the database, the page will echo
 Username already exists and it won't insert the user's new value. It runs
 that far, and echoes the message accordingly. However, if the username is
 new, and does not exist in the database, the query dies (without leaving a
 mysql error).

 I tried changing the Unique IDs in the database, but it doesn't seem to be
 the issue. The syntax seems fine, as I used it for another similar page. Any
 idea why it's dying?


        $check = mysql_query(SELECT * FROM user WHERE
 user_name='$user_name') or die (Unable to query database:.mysql_error());

        $numrows = mysql_num_rows($check) or die (Unable to search
 database:.mysql_error());  - DIES HERE when a new value is entered. no
 mysql_error msg.

bla bla or die(more bla);

is a very bad way of handling error checks. In your particular case,
your foot has been shot off because mysql_num_rows will return 0 (no
rows match the query) and thus the die() is executed - but of course
there's no error in the query, it executed just fine, this we know
already.

Moral: don't use ' or die();' for anything else than hands on debugging purposes

Regards
Peter

-- 
hype
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
/hype

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



Re: [PHP-DB] printf

2010-10-28 Thread Peter Lind
Mysql doesn't have a printf function

Regards
Den 2010 10 29 00:47 skrev Ethan Rosenberg eth...@earthlink.net:
 Dear List -

 I am afraid that I am missing something in a major way.

 mysql printf(%b %d %f %s\n, 123, 123, 123, test);
 ERROR 1064 (42000): You have an error in your SQL syntax; check the
 manual that corresponds to your MySQL server version for the right
 syntax to use near 'printf(%b %d %f %s\n, 123, 123, 123, test)' at
line 1

 Where is my mistake? The code above is copied from the MySQL manual!!

 And while we are on the subject of my ignorance.

 I wish to write to file named Site the letter A, and read it back.

 I wish to write to file named Starter the number 1000 , and read it back.

 How do I do it?

 I'd better ask these questions now, so when they come up in the next
 hour, I will not have to bother you with another email!

 Ethan

 MySQL 5.1 PHP 5 Linux [Debian (sid)]



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



Re: [PHP-DB] products order

2010-09-29 Thread Peter Lind
On 29 September 2010 14:00, Emiliano Boragina
emiliano.borag...@gmail.com wrote:
 Hello,

 A client wants to control the order, the position of the products he
 load. How do I do this?


You store positional data per product, defaulting to no priority in position.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP-DB] how to explain such a regular syntax

2010-08-13 Thread Peter Lind
On 13 August 2010 08:47, win.a win@gmail.com wrote:
 Its was picked from drupal source code and i don't know how does it works.
 This is the code :
 preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $host);

This has got nothing to do with php or php-db - your question is on
regular expressions. Try consulting
http://www.regular-expressions.info/ or get a good book on the topic
like Mastering Regular Expresssions by Jeffrey Friedl.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP-DB] Re: Stuck in apostrophe hell

2010-08-03 Thread Peter Lind
On 3 August 2010 15:04,  paul_s_john...@mnb.uscourts.gov wrote:
 Yes, I may have mixed up the input and output from different iterations of
 running it. Let me try posting this again although it may not be an issue.
 Once again if I enter two sequential apostrophes in the name (O''Brien)
 the INSERT passes right through to MySQL without an error.

 THE INPUT:

 $sql_insert_registration = sprintf(INSERT INTO
  Registrations (
    Class_ID,
    prid,
    Registrant,
    Company,
    Phone,
    Email
  )
 VALUES (
    $_POST[Class_ID],
    $_POST[prid],
    '%s',.
    parseNull($_POST['Company']).,
    '$_POST[Phone]',
    '$_POST[Email]'
 ), mysql_real_escape_string($_POST['Registrant']));

 echo pre$_POST['Registrant.$_POST[Registrant]./pre;
 echo pre.mysql_real_escape_string($_POST[Registrant])./pre;
 echo pre.$sql_insert_registration./pre;


 THE OUTPUT:

 Brian O'Brien
 Brian O\'Brien
 INSERT INTO
  Registrations (
    Class_ID,
    prid,
    Registrant,
    Company,
    Phone,
    Email
  )
 VALUES (
    355,
    257,
    'Brian O\'Brien',NULL,
    '612-456-5678',
    'someb...@somewhere.org'
 )
 Error: You have an error in your SQL syntax; check the manual that
 corresponds to your MySQL server version for the right syntax to use near
 'Brien', 'Class registration confirmation', ' This email ' at line 16


Strangely, you have still failed to provide the input that is actually
sent to mysql. Look at the error code: ... for the right syntax to
use near 'Brien', 'Class registration confirmation', ' This email ' -
Class registration confirmation does not appear anywhere in the
output section you posted but it appears in the mysql error.
 I'd do as Bret suggested and turn on query logging in mysql to see
what is actually received.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP-DB] Stuck in apostrophe hell

2010-08-02 Thread Peter Lind
On 2 August 2010 22:30,  paul_s_john...@mnb.uscourts.gov wrote:
 Before I send the following SQL to MySQL from PHP I print it to screen.
 PHP chokes on it, but I can paste the exact same query from the screen
 directly to MySQL and it works just fine. For example:

 Here's the relevant PHP code:
 ==
 $sql_insert_registration = sprintf(INSERT INTO
  Registrations (
    Class_ID,
    prid,
    Registrant,
    Company,
    Phone,
    Email
  )
 VALUES (
    $_POST[Class_ID],
    $_POST[prid],
    '%s',.
    parseNull($_POST['Company']).,
    '$_POST[Phone]',
    '$_POST[Email]'
 ), mysql_real_escape_string($_POST['Registrant']));

 echo pre.$_POST[Registrant]./pre;
 echo pre.mysql_real_escape_string($_POST[Registrant])./pre;
 echo pre.$sql_insert_registration./pre;

 if (!mysql_query($sql_insert_registration, $con)) {
  die('Error: ' . mysql_error());
 
 ==


 Here's the output:
 ===

 INSERT INTO
  Registrations (
    Class_ID,
    prid,
    Registrant,
    Company,
    Phone,
    Email
  )
 VALUES (
    355,
    257,
    'Brian O\'Brien',NULL,
    '612-456-5678',
    'paul_s_john...@mnb.uscourts.gov'
 )
 Error: You have an error in your SQL syntax; check the manual that
 corresponds to your MySQL server version for the right syntax to use near
 'Brien', 'Class registration confirmation', ' This email ' at line 16
 ==

It's probably nothing but your mysql error does not match your php
output - could you try an updated paste?

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP-DB] Session start

2010-05-14 Thread Peter Lind
On 14 May 2010 18:47, Barry Zimmerman barryzi...@googlemail.com wrote:
 I have a problem with my system, not sure how I can fix this one. A user has
 a log in page and takes them to different pages, now each of these pages has
 a check to make sure they are logged in with the following code:

 session_start();
 if (!(isset($_SESSION['username'])  $_SESSION['username'] != '')) {
 header (Location: login.html);
 exit;
 }

 So if they are not logged in it redirects them to the log in page. No
 problems there.

 Now if a user is not logged in and comes back to that page, it starts the
 session so giving them a session id and redirects them back to thge login
 page. The problem I have is I do NOT want the session to start, I need them
 to hit the log in page with no sessions there. I have tried all sorts but
 just cannot get this to work.

 I have tried adding this to the code.

 session_start();
 if (!(isset($_SESSION['username'])  $_SESSION['username'] != '')) {
 *session_destroy();*
 header (Location: login.html);
 exit;
 }

 But that did not work? Please I am stuck for ideas?


Read the manual on session_destroy. Specifically, if you want to
complete destroy the session, unset the session cookie as well.

On a separate note: why do you care if the session has started or not?
If nothing is stored in the session then there's not much difference
to you.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Peter Lind
On 30 April 2010 20:49, Karl DeSaulniers k...@designdrumm.com wrote:
 No, please confuse me. I need to know this stuff.

 @Peter thanks for that introduction to foreign keys. Since my productoptions
 table is based off of items in products, optionGroups and options, would I
 use foreign keys for this?

If I read you correct, your productoptions table is basically a lookup
table and as such all your fields should be foreign keys. Because,
each field is a reference to another table - and it's vital to data
consistency that they cannot point to a row in a table that doesn't
exist.

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] grabbing from multiple tables

2010-05-01 Thread Peter Lind
On 1 May 2010 10:13, Karl DeSaulniers k...@designdrumm.com wrote:
 What is the SQL query I can use to get an item that has two IDs?
 Something to the effect of...

 $q = SELECT OptID = '$OptID' FROM .PRODUCT_OPTIONS. WHERE ProdID =
 '$ProdID' AND OptGrpID='$OptGrpID';

Close but no cigar.

$q = SELECT OptID FROM .PRODUCT_OPTIONS. WHERE ProdID = '$ProdID'
AND OptGrpID='$OptGrpID';

I am assuming that you have escaped $ProdID and $OptGrpID :)

 Is this correct or am I missing something?
 A single group ID can have multiple option IDs set to it.
 A single product ID can have multiple group IDs set to it.

You're looking at a many-to-many table - a row should be unique given
all three IDs. Only those three IDs together should form a unique row.

 I am trying to single out a product option.
 The option has a group ID and a product ID assigned to it.


I'm starting to wonder about your data model. Should options always be
in groups? I'm guessing that you need one of three things:
1. Split up the product options table. A product can have some
individual options and some group options - these have nothing to do
with each other and you need to be able to set them without regard for
each other.
2. Remove the productOptionID from the product options table. A
product only has option groups, no individual options.
3. Remove the groupOptionID from the product options table. A product
only has individual options, regardless of the option group these
options belong to.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] grabbing from multiple tables

2010-04-30 Thread Peter Lind
On 30 April 2010 12:02, Karl DeSaulniers k...@designdrumm.com wrote:
 Hello All,
 I have a product database. In that database there are several tables dealing
 with individual products.
 I am wanting to set up an editProduct and a productInfo page. For the bulk
 info, I am fine.
 For the product options, I need some guidance.

 I have 4 tables dealing with the options.

 Product table = main product table where productID is set
 Product Options table = table to store product option info. Where productID,
 optionID and OptionGroupID are stored together per ProductID.

 Option Groups table = general option groups EG: Size, Color. Where
 OptionGroupID and OptionGroupName is set.
 Options table = general options EG: Large, Medium, Small, Red, Blue, etc.
 Where OptionID and OptionName is set per OptionGroupID.


 Is there a way for me to call all these tables when adding a product? edit
 product? view product?

MySQL will only allow you to insert into one table at a time. You can
however update several tables at the same time - see
http://dev.mysql.com/doc/refman/5.0/en/update.html

You can select values form multiple tables with the SELECT syntax:
SELECT table1.blah, table2.blah FROM table1, table2 WHERE table1.id =
table2.foreign_key;

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] grabbing from multiple tables

2010-04-30 Thread Peter Lind
On 30 April 2010 12:26, Karl DeSaulniers k...@designdrumm.com wrote:
 Thanks Peter.
 So what is the logic behind foreign keys? Why use them?

Constraints. When using, for example, the InnoDB engine in MySQL, you
can set foreign key fields on tables. These ensure that your record
will always be bound to a proper record in the connected table - so,
for instance, you won't find yourself in the situation that you have
deleted a record from table1 but table2 still references the table1
record. Also, they're very useful for tying models together
automatically, as you can deduce relationships between models by
foreign keys, for instance (this is simplified but covers a lot of
cases).

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] grabbing from multiple tables

2010-04-30 Thread Peter Lind
On 30 April 2010 13:41, DZvonko Nikolov dzvo...@yahoo.com wrote:

 Hi,

 don't confuse the guy.

Don't talk down to the man. He asked questions and got usable answers
including links to where he could find more info.


--
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] php mysql comparing two rows in two columns for username and passwort

2010-04-29 Thread Peter Lind
On 29 April 2010 15:00, Karl DeSaulniers k...@designdrumm.com wrote:
 Hi,
 Maybe try...

 $benutzername = $_GET['username'];
 $pass = $_GET['password'];

 $result = SELECT * FROM usertable WHERE sqlbenutzername='$benutzername';

Don't use values from $_GET without sanitizing first. If using mysql_*
functions, sanitize with mysql_real_escape_string() first.

 while($r = mysql_fetch_row($result)) {
        $dbbenutzer = $r[sqlbenutzername];
        $dbpasswort = $r[sqlpasswort];
 }
       if($benutzername == $dbbenutzer  $pass == $dbpasswort){

This would work but only if you're storing passwords in the database
in clear text - which is a Bad Thing and should be avoided. Hash the
passwords before storing and compare with a hashed version, not the
cleartext.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] php mysql comparing two rows in two columns for username and passwort

2010-04-29 Thread Peter Lind
On 29 April 2010 16:44, Alexander Schunk asch...@gmail.com wrote:
 Hello,

 i have it now as follows:

 while($dbbenutzer = mysql_fetch_assoc($sqlbenutzername))
        while($dbpasswort = mysql_fetch_assoc($sqlpasswort)){

You have things very twisted. Check the code posted by Karl - you only
need *ONE* row containing your *TWO* fields. mysql_fetch_assoc()
retrieves that *ONE* row from a MySQL result set as an array - so
having those two while statements will do you no good.

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] Fwd: Apache log: database shutdown

2010-04-20 Thread Peter Lind
On 20 April 2010 13:37, Kamil Walas kamilwala...@gmail.com wrote:
 I checked. It's looks fine for me, but I paste piece of it relevant to
 apache log:

 Centrum    Mon Apr 19 13:57:02 2010
    INET/inet_error: send errno = 104
 Centrum    Mon Apr 19 13:57:02 2010
    SERVER/process_packet: broken port, server exiting
 Centrum    Mon Apr 19 14:03:49 2010
    INET/inet_error: send errno = 104
 Centrum    Mon Apr 19 14:03:49 2010
    SERVER/process_packet: broken port, server exiting
 Centrum    Mon Apr 19 14:13:57 2010
    INET/inet_error: read errno = 104
 Centrum    Mon Apr 19 14:30:21 2010
    INET/inet_error: read errno = 104
 Centrum    Mon Apr 19 15:22:18 2010
    INET/inet_error: send errno = 104


That hardly looks fine. Googling a bit, I found the following:
http://www.firebirdfaq.org/faq140/
http://www.firebirdfaq.org/faq120/

I'd guess it's a bad connection between Apache and your DB - or Apache
dropping the connection for some other reason.

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] MySQL vs. Session array

2010-04-07 Thread Peter Lind
On 8 April 2010 00:13, 3dgtech syst...@3dgtech.com wrote:
 Quick question. I have an AJAX component that fires a like query for each
 key up event (since it's a like % query there is no indexing or caching
 possible). While everything works fine, I was contemplaining downloading the
 ~1500 rows into a session var as array, offloading the (seperate) mysql
 server and utilizing the (underutilized) php server. Any thoughts?

You'd be better off storing stuff in memcache than session, would be
my opinion - session is per user, so you wouldn't get much cache reuse
out of it.

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
/hype

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



Re: [PHP-DB] Random pick

2010-01-25 Thread Peter Beckman

On Mon, 25 Jan 2010, Karl DeSaulniers wrote:


Hello List,
Trying to learn the right way to code this line.
Can anyone tell me if I am doing this the right way?

if $req_user_level == 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 ? 
Guest || Regular User || Intl. User || Contractor || Employee || 
Sales || Investor || Human Resources || Administrator;


I am wanting to stray from the if(foo == bar) { routine. ;)


 if (in_array($req_user_level, array(0,1,2,3,4,5,6,7,8,9,Guest,...))) {
 // do stuff
 }

---
Peter Beckman  Internet Guy
beck...@angryox.com http://www.angryox.com/
---

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



Re: [PHP-DB] Random pick

2010-01-25 Thread Peter Beckman

On Mon, 25 Jan 2010, Karl DeSaulniers wrote:


Thank you for this as well.
Question? What part is in_array playing?
Is it comparing $req_user_level to array()?
Because the text Guest, etc.. is not in $req_user_level on the database.
In other words, is it checking the value of $req_user_level to see if Guest 
is in it?


 Sorry, I missed the question mark.  in_array isn't appropriate here.  The
 previous poster has it right, assuming $req_user_level is an integer of
 0..9.

 $levels = array(Guest, Regular User, 'Intl. User', ...)
 // the array is   0,  1,   2 , ...)

 Going a little further:

if (!empty($levels[$req_user_level])) {  // is both set and doesn't 
evaluate to false
echo The user is a {$levels[$req_user_level]}.\n;
} else {
//  The $req_user_level was not a valid level.
echo The returned req_user_level was not valid.\n;
}

 Which would output, if $req_user_level was 1 (one):

The user is a Regular User.

 Then you know you have a valid user level.  Careful though -- sometimes 0
 will be returned on a failure, depending on your SQL.

Beckman
---
Peter Beckman  Internet Guy
beck...@angryox.com http://www.angryox.com/
---

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



Re: [PHP-DB] MySQL query executes outside of PHP, but not in PHP

2009-01-23 Thread Peter Beckman

On Fri, 23 Jan 2009, dave.mcgov...@sungard.com wrote:


Hi,
I am running: PHP 5.2.8, Apache 2.2.11, MySQL 5.1.30 on Win32/XP.

I have a number of queries on my page which are very similar in
structure, and they all work except for the following one.

$mysql['process'] = $client2-real_escape_string($clean['process']);

$sql = SELECT f.name, f.description
   FROM files f, file_mapping m, processes p
   WHERE m.file_id = f.id
   AND p.name = '{$mysql['process']}'
   AND m.process_id = p.id
   AND m.io_flag = 'I';

if ($client2-multi_query($sql)) {
 echo 'h3 class=H3-OTMSMain Input Files/h3';
 do {
   if ($result = $client2-use_result()) {
while ($input = $result-fetch_row()) {
  $filename = $input[0];
  $descr = $input[1];
  echo 'pspan class=FileName'.$filename.'/span'.'
'.$descr.'/p';
}
   $result-close();
   }
   } while ($client2-next_result());
   }


If I echo the $sql, and then run it in MySQL directly, it works fine.  I
have tried replacing the variable in the WHERE clause with a hardcoded
value and and have tried replacing this query with a very basic query
with no variable, but nothing has worked. No error message is returned.

Any suggestions as to what I might check?  Here's an example of an echo
of the following $sql that runs OK in MySQL Query Browser:
SELECT f.name, f.description FROM files f, file_mapping m, processes p
WHERE m.file_id = f.id AND p.name = 'BCOM1AC' AND m.process_id = p.id
AND m.io_flag = 'I'


 error_log(Hey, the SQL is: $sql);

 Then look in your php error log (you do have error logging enabled,
 right?)

 If that SQL in the error log is fine, then your problem is
 $client2-multi_query($sql) -- what does THAT return?  What SHOULD it
 return?  What are you expecting it to return?  Does it return what you
 thought it did?

 When you do if ($var) it can sometimes have unexpected results.  If $var
 is an empty string, it's still true, and executes.  I don't know that
 multi_query SHOULD return, or how to determine if it throws an error, but
 that's one place to start.

 Next, if multi_query worked, then this line is suspect:


   if ($result = $client2-use_result()) {


 This will always result in TRUE, as the assignment will always succeed.
 Change it to:


   if (($result = $client2-use_result())) {


 (added parenthesis)

 What DB library are you using?

---
Peter Beckman  Internet Guy
beck...@angryox.com http://www.angryox.com/
---

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



Re: [PHP-DB] Authenticating user using a web service

2009-01-23 Thread Peter Beckman

Your first problem is that your question is so general and vague, nobody
wants to try and guess at what you are talking about.

Not only that, but you are throwing out some theoretical ideas about 3rd
party interfaces that, IMO, aren't on topic for this mailing list.

If you have a PHP + Database specific question, this is your list.  General
application development questions are not really on point.

On Fri, 23 Jan 2009, Abah Joseph wrote:


Well, I have asked this question before but it seems people don`t understood
me, my intension is to have a second login option like, user may choose to
login with they facebook/myspace/etc id or the local id (my site) on my
site, I want a situation whereby anyone can choose to register or use
an existing social network id and password to login, so I am thinking of
using facebook, but i don`t really understand something about facebook
application, the application always, first go to facebook then redirect back
to the site (callback url), I want all this process done under the hood.

Can someone give me another idea? I will just love any simple idea that will
help.



---
Peter Beckman  Internet Guy
beck...@angryox.com http://www.angryox.com/
---

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



[PHP-DB] php crashes on mysql_connect

2008-12-11 Thread Peter Degen-Portnoy
Hi Folks,

I've been banging against this for a while and have narrowed it down to a
completely repeatable and tiny test case.

The issue is that any mysql_connect call hangs and causes a segmentation
fault in php5ts.dll.  Here are the specifics:

I am running on Windows XP, SP2, Single Athlon 64 3200+ CPU.  I have
recently installed the following:

MySQL version 5.1.30 for Win32
Apache version 2.2.10 for Win32
PHP 5.2.8

I have tried both the zip file and the msi installer to install PHP, more
recently the MSI installer.  I added the GD, mysql, mysqli and multi-byte
string extensions.

I have configured Apache  MySQL and have created some databases, which I
can access through mysql and Navicat.  I have used a simple phpinfo.php
script to track down an incorrect libmysql.dll in my path and have
eliminated that and have verified that the client version of libmysql is
5.1.30 in phpinfo.

I have a tiny script to test the mysql connectivity from php:

?php
mysql_connect('localhost', 'root', 'root');
print('Past mysql_connect');
?

but if I run this through apache, httpd.exe crashes with the following error
(recorded in the application event log)

Faulting application httpd.exe, version 2.2.10.0, faulting module
php5ts.dll, version 5.2.8.8, fault address 0xac5a.

And if I run it from the command line with

c:\php -f test_db_connection.php

I get a very similar error in the application event log:

Faulting application php.exe, version 5.2.8.8, faulting module php5ts.dll,
version 5.2.8.8, fault address 0xac5a.

I've not been able to get a backtrace for the crash and I don't have a
debugger into which I can build and put php.

I would greatly appreciate some ideas on how I can figure out where the
problem lies.  I belive that I have narrowed the problem down to a very
straight database connection issue and was pretty certain that it had to do
with an old libmysql.dll on my path, until I tracked the bugger down and
eliminated it, but to no avail.

Thanks in advance for your thoughts.

Yours,

Peter


Re: [PHP-DB] php crashes on mysql_connect

2008-12-11 Thread Peter Degen-Portnoy
Thanks, Chris.

- Peter

On Fri, Dec 12, 2008 at 1:10 AM, Chris dmag...@gmail.com wrote:

 Peter Degen-Portnoy wrote:

 Hi Folks,

 I've been banging against this for a while and have narrowed it down to a
 completely repeatable and tiny test case.


 http://bugs.php.net/

 Best place to post it and get it fixed.

 --
 Postgresql  php tutorials
 http://www.designmagick.com/




[PHP-DB] Re: php and mssql on seperate servers

2008-04-24 Thread Peter Westergaard

Rick Taylor wrote:
I'm new to PHP and having issues.  We have seperate servers for them.  
We can use ODBC to test the connection and it works fine.  However, when 
we try to run the site we get a message of *** Error: Unable to Connect 
to Database. Please Try Again Later. ***


We are using a custom app that we aren't getting a lot of assistance 
with. The relevant lines in the app are:

define(DBHOST, //database server name);
define(DBUSER, user);
define(DBPASS, password);

if(!$dbCon=mssql_connect(DBHOST,DBUSER,DBPASS)) $error = Unable to 
Connect to Database. Please Try Again Later.;


Can anyone assist a noob php user?

thanks


Thanks for removing any extraneous/irrelevant code.  Nice, well-laid-out 
question.


The obvious follow-up-question presents itself, so forgive me for asking 
if I'm underestimating, but you didn't mention whether or not you were 
quoting it verbatim, or whether you had replaced your database host, 
userid, and password from the code before you pasted it here.


Just in case it's the really obvious problem, you should be aware that 
you are expected to fill in those lines as relevant to your MSSQL server.


For example, if the MSSQL serer was living on a server called 
TORFOX001 (or //TORFOX001 in the MS local-network naming format), 
and you'd set it up with a userid zippy with password pinh34d, those 
lines should be modified to read:


define(DBHOST, //TORFOX001);
define(DBUSER, zippy);
define(DBPASS, pinh34d);

-P

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



[PHP-DB] Re: php-db Digest: Sending multiple values from a form having same field names.

2008-03-19 Thread Peter Westergaard

Your line :

input type=hidden name=field_id value=?php echo $field_id;? /


Should probably be:

input type=hidden name=?php echo $field_id; ? value=?php echo 
$field_id;? /


So that each field's name isn't the string field_id, but rather is 
each field's unique ID.




Hi,

How can I send multiple values from a form to be stored in a database, as
name of the fields is the same?

For example:

?php
foreach ($field_data as $field) {

 $field_name=$field[field_name];
 $field_id=$field[field_id];
 $datatype=$field[datatype_name];

?
input type=hidden name=field_id value=?php echo $field_id;? /
tr
tdstrong?php echo $field_name;?strong/td
?php
 if ($datatype==text || $datatype==integer) {
echo tdinput type=\text\ name=\field_data\/td;
 }
 elseif ($datatype==textarea) {
  echo tdtextarea rows=\10\ cols=\100\
name=\field_data\/textareabr/td;
  }
  echo /tr;
}
?

This creates a form with field names and text box or textarea box next to
each field name depending on the datatype. After the user enters the
values in the text or textarea and clicks submit, the values should get
stored in a database. But what is happening is that only the value entered
in the last field of the form is getting entered into the database.
This code is embedded in an application which is having an inbuilt
structure of taking the values from a form in a hash. Since key is the
same (i.e. field_id) everytime, the value gets overwritten and only the
last value gets stored in db. But I am not able to work out a solution for
this.
I hope I am able to make my problem clear enough.

Thanks,
Suamya.

 
-
DISCLAIMER:- 
  The information in this e-mail is confidential, and is intended 
solely for the addressee or addressees. If you are not the intended recipient,
 please delete the mail and kindly notify the sender of misdelivery. Any 
unauthorised use or disclosure of the contents of the mail is not permitted 
and may be unlawful.

-

 Scanned By MailScanner

  




Subject:
Re: [PHP] Fastest way to get table records' number
From:
Daniel Brown [EMAIL PROTECTED]
Date:
Wed, 19 Mar 2008 09:42:07 -0400
To:
Shelley [EMAIL PROTECTED]

To:
Shelley [EMAIL PROTECTED]
CC:
[EMAIL PROTECTED], PHP DB php-db@lists.php.net


On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote:
  

Hi all,

 What do you think is the FASTEST sql to get the total number of a table
 with millions of records?



That question would be better on the PHP-DB list, so for archive's
sake, I'm CC'ing that list.

$sql = SELECT COUNT(*) FROM your_table;

  



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



[PHP-DB] Re: Kesalahan posting: Don Komo

2008-03-19 Thread Peter Westergaard

Oops, I'm sorry, recovering from a 102 fever the other day.  :)

You don't want duplicate field IDs anywhere, really.  The hidden fields 
are probably completely unnecessary; what do you use them for?


It's the latter section you really need to correct, however, where each 
data field's name is being set to field_data all the time.  That's not 
going to help you push it back into the database.  the data won't be 
distinguished, and all but one will be discarded.   also, in my 
suggested corrections, I assume you're passing default values to this 
page in the field_data elements.


-P


?php
if ($datatype==text || $datatype==integer) {
   echo tdinput type=\text\ name=\$field_id\ 
value=\$field_data\/td;

}
elseif ($datatype==textarea) {
 echo tdtextarea rows=\10\ cols=\100\
name=\$field_id\$field_data/textareabr/td;
 }
 echo /tr;
}
?





Your line :

input type=hidden name=field_id value=?php echo $field_id;? /


Should probably be:

input type=hidden name=?php echo $field_id; ? value=?php echo 
$field_id;? /



So that each field's name isn't the string field_id, but rather is 
each field's unique ID.




Hi,

How can I send multiple values from a form to be stored in a 
database, as

name of the fields is the same?

For example:

?php
foreach ($field_data as $field) {

 $field_name=$field[field_name];
 $field_id=$field[field_id];
 $datatype=$field[datatype_name];

?
input type=hidden name=field_id value=?php echo $field_id;? /
tr
tdstrong?php echo $field_name;?strong/td
?php
 if ($datatype==text || $datatype==integer) {
echo tdinput type=\text\ name=\field_data\/td;
 }
 elseif ($datatype==textarea) {
  echo tdtextarea rows=\10\ cols=\100\
name=\field_data\/textareabr/td;
  }
  echo /tr;
}
?

This creates a form with field names and text box or textarea box 
next to

each field name depending on the datatype. After the user enters the
values in the text or textarea and clicks submit, the values should get
stored in a database. But what is happening is that only the value 
entered

in the last field of the form is getting entered into the database.
This code is embedded in an application which is having an inbuilt
structure of taking the values from a form in a hash. Since key is the
same (i.e. field_id) everytime, the value gets overwritten and only the
last value gets stored in db. But I am not able to work out a 
solution for

this.
I hope I am able to make my problem clear enough.

Thanks,
Suamya.

 
- 

DISCLAIMER:-   The information in this e-mail is 
confidential, and is intended solely for the addressee or addressees. 
If you are not the intended recipient,
 please delete the mail and kindly notify the sender of misdelivery. 
Any unauthorised use or disclosure of the contents of the mail is not 
permitted and may be unlawful.
- 



 Scanned By MailScanner

 



Subject:
Re: [PHP] Fastest way to get table records' number
From:
Daniel Brown [EMAIL PROTECTED]
Date:
Wed, 19 Mar 2008 09:42:07 -0400
To:
Shelley [EMAIL PROTECTED]

To:
Shelley [EMAIL PROTECTED]
CC:
[EMAIL PROTECTED], PHP DB php-db@lists.php.net


On Tue, Mar 18, 2008 at 11:43 PM, Shelley [EMAIL PROTECTED] wrote:
 

Hi all,

 What do you think is the FASTEST sql to get the total number of a 
table

 with millions of records?



That question would be better on the PHP-DB list, so for archive's
sake, I'm CC'ing that list.

$sql = SELECT COUNT(*) FROM your_table;

  






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



[PHP-DB] Re: A little SQL help

2008-01-31 Thread Peter Westergaard

Bastien,

I think it would help if you described what result you were expecting, 
what version of SQL you're using, and where your error is occurring. 

I'm going to assume you're looking for a list of tours (including event 
start and end dates, event name, and result) for a specific angler (in 
this case, angler 1). 

I personally would avoid putting the CASE logic into the SQL statement.  
Just pull angler_results.result from the query and use PHP logic to 
output N/A instead of the results if it's NULL, at output time, 
especially if that's where you're having your problem.


What problem are you actually encountering though?

-P




Hi All,
 
Got myself stuck in a little sql here and can't seem to work out what I am doing wrong
 
SELECT 
  DISTINCT (tour.record_id), tour.event_start_date, tour.event_end_date, tour.event_name,CASE WHEN result is NULLTHEN 'N/A'ELSE angler_results.resultEND CASE 
FROM 
  tourLEFT OUTER JOIN angler_results 
ON angler_results.tour_id = tour.record_idWHERE angler_results.angler_id =1
 
where the table TOUR is as above in the primary part of the select and table ANGLER_RESULTS is (record_id, tour_id, angler_id, result)
 
 
Any ideas?
 
Bastien
 
  


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



[PHP-DB] Re: php-db Digest 14 Jan 2008 19:48:27 -0000 Issue 3947

2008-01-14 Thread Peter Westergaard

Miguel -

MD5() is a hash function, not an encryption function. A hash function 
cannot be reversed. 

One of the reasons some sites use MD5() for passwords is so that the 
passwords are never even stored on the server, only the hash.   So even 
the site's database admin can't figure out the passwords of users. 

A hash is a little like a checksum.  Two files can have the same 
checksum even if they're completely different files.  But good luck to 
you if you want to CREATE a file with a specific checksum. 


-Peter





Is there a function opposite to md5()??

  


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



[PHP-DB] pdo_firebird: RETURNING patch (Bug #43246)

2007-11-12 Thread Hans-Peter Oeri
Hi!

I have bug #43246 open and just posted a patch comment there. As I
don't know how to (or cannot) upload patches in the bug system.

The problem is:
Queries ending in RETURNING ... get qualified as stored procedure
calls. Contrary to the docs, the PDOStatement-execute call is returning
the stored procedure's return value...

Just eliminating this undocumented behaviour clears the problem!

As I don't assume authority in php internals, the attached patch
(against CVS PHP_5_3) only out-ifdefs the corrupt parts.

Greets
HPO
diff -u php5-orig/ext/pdo_firebird/firebird_statement.c 
php5/ext/pdo_firebird/firebird_statement.c
--- php5-orig/ext/pdo_firebird/firebird_statement.c 2007-11-12 
16:59:34.0 +0100
+++ php5/ext/pdo_firebird/firebird_statement.c  2007-11-12 16:58:46.0 
+0100
@@ -99,11 +99,15 @@

/* assume all params have been bound */

+#if 0
if ((S-statement_type == isc_info_sql_stmt_exec_procedure 
isc_dsql_execute2(H-isc_status, H-tr, 
S-stmt, PDO_FB_SQLDA_VERSION,
S-in_sqlda, S-out_sqlda))
|| isc_dsql_execute(H-isc_status, H-tr, 
S-stmt, PDO_FB_SQLDA_VERSION,

S-in_sqlda)) {
+#else
+   if (isc_dsql_execute(H-isc_status, H-tr, S-stmt, 
PDO_FB_SQLDA_VERSION, S-in_sqlda)) {
+#endif
break;
}

@@ -138,9 +142,11 @@

/* an EXECUTE PROCEDURE statement can be fetched from once, 
without calling the API, because
 * the result was returned in the execute call */
+#if 0
if (S-statement_type == isc_info_sql_stmt_exec_procedure) {
S-exhausted = 1;
} else {
+#endif
if (isc_dsql_fetch(H-isc_status, S-stmt, 
PDO_FB_SQLDA_VERSION, S-out_sqlda)) {
if (H-isc_status[0]  H-isc_status[1]) {
RECORD_ERROR(stmt);
@@ -148,7 +154,9 @@
S-exhausted = 1;
return 0;
}
+#if 0
}
+#endif
return 1;
}
return 0;

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

[PHP-DB] pdo_firebird: PDOStatement-closeCursor

2007-11-12 Thread Hans-Peter Oeri
Hi!

I fell out of bed as I noticed that PDOStatement-closeCursor is not
implemented for pdo_firebird.

Again, I'm not a php guru, but patched my version with the attached diff.

HPO
--- php5-orig/ext/pdo_firebird/firebird_statement.c 2007-11-12 
21:54:13.0 +0100
+++ php5/ext/pdo_firebird/firebird_statement.c  2007-11-12 21:51:03.0 
+0100
@@ -621,6 +620,22 @@
 }
 /* }}} */

+static int firebird_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
+{
+   pdo_firebird_stmt *S = (pdo_firebird_stmt*)stmt-driver_data;
+   int result = 1;
+
+   /* close the statement */
+   if (isc_dsql_free_statement(S-H-isc_status, S-stmt, DSQL_close)) {
+   RECORD_ERROR(stmt);
+   result = 0;
+   }
+
+   return result;
+}
+/* }}} */
+
+
 struct pdo_stmt_methods firebird_stmt_methods = { /* {{{ */
firebird_stmt_dtor,
firebird_stmt_execute,
@@ -629,7 +644,10 @@
firebird_stmt_get_col,
firebird_stmt_param_hook,
firebird_stmt_set_attribute,
-   firebird_stmt_get_attribute
+   firebird_stmt_get_attribute,
+   NULL,
+   NULL,
+   firebird_stmt_cursor_closer
 };
 /* }}} */

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

[PHP-DB] Job : Looking for a php / mysql programmer in or near Birmingham uk.

2007-10-23 Thread peter lovatt
Hi

I am a looking for a php / mysql programmer in, or within reach, of
Birmingham UK

I
have a variety of work including some very interesting and challenging
projects.

You can work here or from home, or a bit of both.

If you are interested email me [EMAIL PROTECTED] or call 0121 242 1473

I would consider a freelancer or full time employee, rates -
generous for the right person.

Peter


Re: [PHP-DB] Remote DB Connection: Pros and Cons?

2007-10-11 Thread peter lovatt
Hi

You would be better off with the database server and php on the same server
- both sites.

You will find there is significant lag if there is a poor
connection between the web and database server, but if you are just
accessing web pages
and updating data, even with large pages there is not much delay.

You could always try both permutations and see, but that has been my
experience.

Peter



On 12/10/2007, Chris [EMAIL PROTECTED] wrote:

 Tony Grimes wrote:
  Have any of you tried running a PHP website using a remote database
  connection?
 
  We currently have an in-house PHP website driven by a PostgreSQL
 database
  that is HEAVILY administered within the office with an administration
 sister
  site (also PHP).
 
  Problem: the office connection is having trouble keeping up with the
 website
  traffic. Our IT guys want to outsource the whole server to a co-location
  facility, but the administrators don't want the extra lag on the admin
 site.
 
  Is it feasible to host the database and admin site in the office, but
  outsource the website and connect to the office database remotely? Is
 there
  any other way to do this?

 Do the website and admin area reference the same database tables?

 If they don't, split the database up and keep the website db on the
 website server and the other internally.

 If they do, which one is the 'primary' set? ie which one gets updated?

 You could use replication to keep them in sync (http://www.slony.info/
 for example).

 --
 Postgresql  php tutorials
 http://www.designmagick.com/

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




Re: [PHP-DB] First and Last ID of a table

2007-07-11 Thread Peter Beckman

On Wed, 11 Jul 2007, Matt Leonhardt wrote:


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

SELECT MIN(id), MAX(id) FROM mytable


As an aside, is you are using associative arrays, be sure to use the
following keys:

$array['MIN(id)'] and $array['MAX(id)']

Just something I figured out recently :)


 or use select min(id) min, max(id) max from mytable

 then access as $array['min'] and $array['max']

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.angryox.com/
---
** PLEASE NOTE PurpleCow.com IS NOW AngryOx.com DO NOT USE PurpleCow.com **
** PurpleCow.com is now owned by City Auto Credit LLC as of May 23, 2007 **
---

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



Re: [PHP-DB] A good PHP Ajax tutorial

2007-02-25 Thread Peter Beckman

On Sun, 25 Feb 2007, Denis L. Menezes wrote:


Can someone please suggest a good pHP/Ajax tutorial?


 Use mootools, http://mootools.net/

 Best JS library around, does all sorts of neat AJAXy animations as well as
 handling the backend cross-browser.

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Access denied for user...sometimes???

2007-02-21 Thread Peter Beckman

On Wed, 21 Feb 2007, James Garfield wrote:

I've got 5.0.27-standard installed on an Intel Mac, using the preinstalled 
version of Apache and my own installation of PHP 4.4.4. I use this machine 
for development work and don't make it available to anyone else. I've got an 
instance of a PHP application running, and it works...but not all of the 
time!!! I created the user that accesses my MySQL via the following commands;


use [web_db_name];
grant select, insert, update, delete on *.* to '[new_user]'@'%' identified by 
'[new_password]';


I'm able to do everything expected from the command line mysql tool, but on 
the PHP side it fails more than half of the time:


Warning: mysql_connect() [function.mysql-connect]: Access denied for user 
'[new_user]'@'[my_current_dhcp_ip]' (using password: YES) in 
/[path]/[to]/[page]/[on]/[server]/index.php on line 66


This leaves the question: since MySQL is behaving normally otherwise, I'm 
using a host of '%' and my IP isn't changing, does anybody know what the 
problem is with PHP???


TIA,
James


 flush privileges

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] Strange action with =

2007-02-12 Thread Peter Beckman

I'm looping through an array and I did this:

$rate = $mydata[$prefix];

Now, in some cases $mydata[$prefix] wasn't set/defined, so I expected $rate
to not be defined, or at least point to something that wasn't defined.

Instead, PHP 5.1.6 set $mydata[$prefix] to nothing.

If I had:

$mydata[1] = 3;
$mydata[3] = 2;
$mydata[5] = 1;

And did a loop from $i=1; $i++; $i=5 I'd get:

$mydata[1] = 3;
$mydata[2] = ;
$mydata[3] = 2;
$mydata[4] = ;
$mydata[5] = 1;

Is this expected?  A bug?  Fixed in 5.2.0?  I know I shouldn't set a
reference to a variable that doesn't exist, but the expected result is a
warning/error, not for PHP to populate an array.

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Strange action with =

2007-02-12 Thread Peter Beckman

On Tue, 13 Feb 2007, bedul wrote:


sry i don't get what u mean??


I'm looping through an array and I did this:

 $rate = $mydata[$prefix];


 This is how you assign a variable by reference.  $rate should be a
 reference to $mydata[$prefix], not a copy.  If I change the value of
 $rate, the value of $mydata[$prefix] is also changed, and vice versa.


Now, in some cases $mydata[$prefix] wasn't set/defined, so I expected
$rate to not be defined, or at least point to something that wasn't
defined.

Instead, PHP 5.1.6 set $mydata[$prefix] to nothing.

If I had:

 $mydata[1] = 3;
 $mydata[3] = 2;
 $mydata[5] = 1;

And did a loop from $i=1; $i++; $i=5 I'd get:

 $mydata[1] = 3;
 $mydata[2] = ;
 $mydata[3] = 2;
 $mydata[4] = ;
 $mydata[5] = 1;


the reason mydata2 empty was because it don't have value in it!!

full source plz
why u don't try this

$txt.=ol;
foreach($mydata as $nm=$val){
   $txt.=\nli $nm = $val;
   $txt2=br\$mydata[$nm] = $val;
}
$txt.=/ol;

print $txt;


 Because I'm trying to point out a problem with PHP, where setting a
 reference when the other side is undefined or not set, PHP creates a
 reference to a previously non-existent array item, just by setting a
 reference.  I don't think that should happen.

 Your code doesn't set anything by reference.


Is this expected?  A bug?  Fixed in 5.2.0?  I know I shouldn't set a
reference to a variable that doesn't exist, but the expected result is a
warning/error, not for PHP to populate an array.


we should cross check again.


 I don't know what you mean.

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Session Problem

2007-01-11 Thread Peter Beckman

1. Is session support compiled into PHP, or if not, is the module there and
being loaded?  phpinfo() will tell you.

 If not, recompile PHP or build the dynamic module to support sessions.

2. If so, check the location of session.save_files and make sure it is
writable by the web server user/group.  If not, you must change this.

Beckman

On Fri, 12 Jan 2007, [EMAIL PROTECTED] wrote:


Dear All,



I need some help please...



I'm developing an web application using PHP/MySQL, and its has been
running on my company.



I'm planning to migrate the system on a new server.

I have installed everything that are needed on the new server to running
the web application.

But I'm confusing that the session isn't running.



For your information, I've setting all configurations (MySQL  PHP),
included register globals to Off.

I have trying to re-install the web server  MySQL, but it still not
running...



Please advice...



Thanks  Regards,



Anita




---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] This won't work in MySQL 4.1.10

2006-12-27 Thread Peter Karlsson
 but it runs fine in 4.1.20. In .10 I get an error message about  
unknown column c. I built the sql with help from the comments from  
the MySQL website manual and have to admit that I don't fully  
understand it all ;). Is there a way to  solve this without upgrading  
the server?



SELECT DISTINCT O.id, O.header, O.state, O.prio, O.publication_date,  
O.user_id, MATCH (C.body) AGAINST ('mysearch') AS relevance FROM  
texts AS C JOIN jobs AS O ON C.job_id=O.id WHERE O.paper_id = 1 AND  
MATCH (c.body) AGAINST('+mysearch' IN BOOLEAN MODE) HAVING relevance  
 0.2 ORDER BY relevance DESC


Best regards,

Peter

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



[PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Peter Beckman

I have a table:

id fkid   foobar
1  1  345yellow
2  1  34 red
3  2  3459   green
4  2  345brown

I want to select the largest value of foo for a unique fkid, and return
bar, the results ordered by bar.  In this case, 345 is the largest value of
foo for fkid 1, and 3459 is the largest for fkid 2.  green comes before
yellow.  My desired result set would be:

fkid   foobar
2  3459   green
1  345yellow

How would I write that in SQL?  fkid and foo are ints, bar is a varchar.

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Peter Beckman

On Mon, 13 Nov 2006, [EMAIL PROTECTED] wrote:


Actually, that should not work, it should give you an error.

This should work:

SELECT `fkid`,max(`foo`) as foo,`bar` FROM `test2` GROUP BY `fkid`  ORDER BY 
`bar` ASC


Yes, but if the data is in a different order that fails and doesn't maintain 
row order:

mysql create temporary table test2 (id tinyint,fkid tinyint, foo smallint, 
bar varchar(20));
mysql insert into test2 values (1,1,34,'red'), (2,1,345,'yellow'), 
(3,2,345,'brown'), (4,2,3459,'green');
mysql select * from test2;
+--+--+--++
| id   | fkid | foo  | bar|
+--+--+--++
|1 |1 |   34 | red|
|2 |1 |  345 | yellow |
|3 |2 |  345 | brown  |
|4 |2 | 3459 | green  |
+--+--+--++
mysql SELECT `fkid`,max(`foo`) as foo,`bar` FROM `test2` GROUP BY `fkid`  
ORDER BY `bar` ASC;
+--+--+---+
| fkid | foo  | bar   |
+--+--+---+
|2 | 3459 | brown |
|1 |  345 | red   |
+--+--+---+
2 rows in set (0.00 sec)

Notice how 3459 is supposed to be green but reports brown, and 345 should
be yellow but reports red?

Any other solutions that maintain row integrity?

Beckman


Miguel Guirao wrote:

select max(bar) from mytable where unique fkid order by bar asc

as far as I remember!!

-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]
Sent: Lunes, 13 de Noviembre de 2006 04:59 p.m.
To: PHP-DB Mailing List
Subject: [PHP-DB] MySQL SQL Query Help


I have a table:

id fkid   foobar
1  1  345yellow
2  1  34 red
3  2  3459   green
4  2  345brown

I want to select the largest value of foo for a unique fkid, and return
bar, the results ordered by bar.  In this case, 345 is the largest value of
foo for fkid 1, and 3459 is the largest for fkid 2.  green comes before
yellow.  My desired result set would be:

 fkid   foobar
 2  3459   green
 1  345yellow

How would I write that in SQL?  fkid and foo are ints, bar is a varchar.

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---




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



---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



RE: [PHP-DB] Direct Access to an Array Item?

2006-08-09 Thread Peter Beckman

On Wed, 9 Aug 2006, Bastien Koert wrote:


use mysql_result

mysql_result ( $result, 0,  2 )

where 2 is the offset of the fields in the row


 In one line of code, I want to fetch the row into a variable, and test a
 variable within that row.

 I want to know how to do this both within a DB query and outside of.

 Your solution is valid, but not what I'm looking for.

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] Direct Access to an Array Item?

2006-08-08 Thread Peter Beckman

I want to access a variable within a function-returned array without
setting the array to a variable first.  Example -- test for equal to string
'foo' on the 4th element of a returned fetch row:

if (($row = mysql_fetch_row($result))[3] == 'foo') {
$user = $row;
}

or

$bar = explode('#', $str)[2];

I know I can do this in perl, but can it be done in PHP?  Obviously this is
pseudo code, it doesn't actually work, but I wonder if there is a way that
escapes me currently?

I know I can assign the result to a variable and then test the element; I
am addicted to trying to cut down the amount and complexity of code.  Even
if you disagree with my goal as good computing practices, I simply want to
know if what I ask is possible, and if so, how. :-)

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] detecting negative numbers

2006-07-16 Thread Peter Beckman

On Sun, 16 Jul 2006, Dave W wrote:


Currently I have this:

if($quant  $amount) {echo You don't have that many!; }

$quant is the user inputted amount and $amount is the amount that they
actually have. Is there any way of checking if the result is negative rather
than doing what I have above?


 I'm not sure which result you are refering to, but this echo's if:
$quant is greater than $amount
$amount is less than 0
$quant is less than 0

 if ($quant  $amount or $amount  0 or $quant  0) {
echo You don't have that many!;
 }

---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] spell checking and did you mean?

2006-03-23 Thread peter lovatt
Hi All

I am looking to check whether a keyword a user has entered already
exists in the database

I can find exact matches, but I am having trouble with typos.

I am looking for something like Google's did you mean if you type in
a close match.

SO if someone types in saet it returns did you mean  seat ?

Any suggestions which is best - SOUNDEX in MySql or  the php functions
 levenshtein(), soundex(),metaphone() or similar_text() on the
returned result.

Any other suggestions welcome.

Thanks

Peter

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



Re: [PHP-DB] Text file (rw) question...

2006-03-14 Thread Peter Beckman

pear install Config

Now you can load a config file like that with a single command, load it
into an array, modify values, then write it back.

http://pear.php.net/package/Config

It is fantastic.

Beckman

On Tue, 14 Mar 2006, Rob W. wrote:

That works, but it just throws it in to a big loop and fills up the file, any 
suggestions?



- Original Message - From: Chris [EMAIL PROTECTED]
To: Rob W. [EMAIL PROTECTED]
Cc: php-db@lists.php.net
Sent: Tuesday, March 14, 2006 5:54 PM
Subject: Re: [PHP-DB] Text file (rw) question...



Rob W. wrote:

Ok, The fix is just doing something like this...

list($variable, $data) = explode(=, $x);

But now my problem is trying to figure out how to update that data with 
form post ect...


So the main page would get

MaxUser=32

It would read that info and put it in to a form field, which I have.

Now I gotta get it to take and make it so that a new value can be put in 
that field and updated back in to the text file. I have searched all over 
google for about 4 hrs looking for something like this but no go, any help 
would be appricated.


This is a simple example but it should work for you:

$new_textcontent = ;

foreach($_POST as $area = $value) {
  $new_textcontent .= $area . = . $value . \n;
}

$fp = fopen($filename, 'w');
fputs($fp, $new_textcontent);
fclose($fp);




- Original Message - From: Dwight Altman [EMAIL PROTECTED]
To: 'Rob W.' [EMAIL PROTECTED]; php-db@lists.php.net
Sent: Tuesday, March 14, 2006 9:13 AM
Subject: RE: [PHP-DB] Text file (rw) question...


How about posting your solution as well?  Maybe someone will find it 
useful.


-Original Message-
From: Rob W. [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 14, 2006 2:07 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Text file (rw) question...

Nevermind. I figured it out.


- Original Message - From: Rob W. [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Tuesday, March 14, 2006 1:45 AM
Subject: [PHP-DB] Text file (rw) question...


I'm trying to figure out how to read specific data from a text file that
is already written. Example

MaxUser=3D32
PortBase=3D8000

I want to be able to have php read them specific pieces of info so I can
put them in to forms and update them via php.
Any help would be appreciated.

--

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








--
Postgresql  php tutorials
http://www.designmagick.com/

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




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



---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Storing Credit Cards, Passwords, Securely, two-way encryption

2006-01-06 Thread Peter Beckman

On Fri, 6 Jan 2006, Neil Smith [MVP, Digital media] wrote:


Peter Beckman wrote:
So I'm thinking about how to save credit card numbers in the DB, for
re-charging cards for subscriptions, new orders, etc.

 Yes yes, lawsuits, scary, etc.


I'm glad you're so blase about this and the threat of your business going


 Not blase -- just sick of hearing don't do it you'll get sued
 impossible what's wrong with you

 I want to secure this information, responsibly.  How? (You answer this
 below)


Security by obscurity is a myth.


 I believe you -- and if obscurity is a myth, let's document how it can be
 done safely for all the world to see and learn!


*DO NOT* store any credit card numbers on any publically accessible
system. Ever. Period.


 Sometimes when questions are asked a background of the knowledge of the
 poster is not given.  I would never do that.  A server that is connected
 to the internet directly storing credit cards is asking for a lawsuit.
 It's got a sign with please hack me on it.

OK now to the candy : I've had this book a while, and it's one of the most 
insightful and well researched (from experience) books on security I've ever 
read. In fact - so good I'm going to go to the trouble to retype an excerpt 
of a section called One-Way Credit Card Data Path for Top Security


(Bob Toxen) have come up with the concept of a one-way credit card data path.


 Now THAT is exactly what I was looking for -- THANKS!  I'll go get the
 book.


(snipped section about spot welded steel pipes encasing LAN cable !)


 *laugh* That might be a bit of overkill... but I get the idea.

The CC server then contacts the processing bank through the private network 
to charge the amt, store the authorisastion number if successful and returns 
either Success or an appropriate error message


 Obviously most CC auths are via the 'net + SSL, private networks don't
 apply (and they are kind of cost prohibitive).  If you have a
 router/firewall/ipfw between your CC and the 'net, blocking incoming but
 allowing outgoing to your cc auth host ip(s), is that good enough?  What
 else can be done?


As Bob's book is so bloody good, here's the ASIN for it in case you want
to read all 650 pages of good advice ;-)
http://www.amazon.com/gp/product/0130464562/qid=1136589506/sr=8-1/ref=pd_bbs_1/104-3174210-9795945?n=507846


 Thank you Neil -- sold!

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Re: Storing Credit Cards, Passwords, Securely, two-way encryption

2006-01-06 Thread Peter Beckman

On Fri, 6 Jan 2006, Dan Baker wrote:


Peter Beckman [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

So I'm thinking about how to save credit card numbers in the DB, for
re-charging cards for subscriptions, new orders, etc.

I'm also thinking about how to save passwords in the DB, not plaintext,
but
not one-way encrypted either.

Any suggestions?  How would I secure the database?  I'm thinking some
abstract process in code, or something -- security through obscurity.


[Summary: Call Verisign, pay THEM to store credit cards for you]


 What, exactly, does VeriSign do, that makes you so sure that they have
 secured the credit card information any better than I could, using a
 well-thought-out system?  Do you even know?  You just hear VeriSign and
 believe they have smart people that have more resources available to them
 to do a better job securing the data?

 Maybe this makes sense if you are doing a few hundred or a few thousand
 dollars of business a month, but if you are planning on doing $5,000 to
 $10,000 a day, it is a lot of added expense to have someone else do it,
 when I could have it done internally.  It is the how.

 Please, no more replies saying don't do it.

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] Storing Credit Cards, Passwords, Securely, two-way encryption

2006-01-05 Thread Peter Beckman

So I'm thinking about how to save credit card numbers in the DB, for
re-charging cards for subscriptions, new orders, etc.

I'm also thinking about how to save passwords in the DB, not plaintext, but
not one-way encrypted either.

Any suggestions?  How would I secure the database?  I'm thinking some
abstract process in code, or something -- security through obscurity.

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Storing Credit Cards, Passwords, Securely, two-way encryption

2006-01-05 Thread Peter Beckman

On Thu, 5 Jan 2006, John Meyer wrote:


Peter Beckman wrote:

So I'm thinking about how to save credit card numbers in the DB, for
re-charging cards for subscriptions, new orders, etc.


Why, is the first question I would ask you.



So I'm thinking about how to save credit card numbers in the DB, for
re-charging cards for subscriptions, new orders, etc.


 Think one-click.  Why did Amazon patent one-click?  Impulse buys -- the I
 want that, now factor.  If you make 13 steps and 12 input boxes, the
 Impulse will probably pass, and you've lost your sale.

 Besides, the user can choose if they want you to save their card info.


First off, on a new order, why wouldn't you just save the authorization
code, instead of the credit card number?  That would be a lot easier.


 Sure.  But see my above point.  I want to be able to re-charge it later
 when the user wants to.

Secondly, you're opening yourself up to 
a _ton_ of lawsuits should anything go awry.   Unless I had a _real_ good 
reason for storing their cc number, I wouldn't, despite the extra step.


 Yes yes, lawsuits, scary, etc.  I was looking for technical solutions,
 i.e. maybe someone knows how USPS.com or Amazon.com or GoDaddy.com (do
 they?) does it.  Or if it is all security via obscurity.

 Best solution yet:

Public key encryption, with additional either secret word padding or
using the users account password to pad/encrypt the card number
(preventing a brute force attack, even if access to the DB is given).

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



Re: [PHP-DB] Storing Credit Cards, Passwords, Securely, two-way encryption

2006-01-05 Thread Peter Beckman

On Fri, 6 Jan 2006, Julien Bonastre wrote:


Any reason why you need to have reversible encryption on the password value??


 No... I just prefer to assume that if someone gets my DB, they might try
 using user/pass pairs on banking sites, or paypal, or other ways, and if I
 can reversible encrypt the password, I can send them an email with their
 password, rather than changing it to something obscure and force them to
 change it again...

 Though at this point, I just decided to md5 the password and call it good
 enough.  I'll just force them to change it if need be.

Generally I simply create some hash from the password, using something akin 
to a MD5 or SHA1 hash of the password string. Or in my paranoid case I use 
the password string, plus all sorts of replicatable combinations of values 
such as length of password, username, registration date/time etc plus weird 
other fixed values I find around the place and environment variables etc, 
then I hash them..


 A good idea; are you just careful then that you don't accidentally update
 the data without re-hasing your passwords?

I am completely psychotic so don't mind me, when I was 15 I wrote my Perl 
driven website http://operation-scifi.com [still Perl driven member system 
and file-system based forum] and I had a real mangler function whereby I 
would extract each character of the password and hash it, then hash the hash 
with the other characters, plus the hash of them with said fixed values from 
server/user account details [age, location etc..] ... It was something in the 
vicinity of a O(6^n+1)th generation hash by the time I had finished where n 
is the length of the original password..


 *laugh* Awesome!  Maybe a bit overkill for password, but still very cool.

 Unfortunately that leaves things unreversable, and if someone got a hold
 of your data AND your code, they could reverse-engineer... It seems
 security is only as good as your weakest link -- obscure code, private
 key, etc...

Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



[PHP-DB] RE: Really dumb Question - Select Many Display Records

2005-09-03 Thread Peter Justus
Hi All

Hoping somebody can help me out here, fairly new to PHP and MYSQL, I
won't waffle on but, but here is my problem!

I have a database with four tables in it, I would like to call the
information from the table into a select menu, once the user has clicked
on an item in the select menu, it will go to a new page where that
tables (all of the columns) information will be displayed 
Example:
User selects an account number, (select Box), user is then redirected to
a new page andon that page user will see information related to that
account number... eg name, and other details!

I hope there is somebody that can help me, and do forgive me if this
seems to be a really noob question, but im pulling my hair out here!

Regards
Peter 

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



[PHP-DB] Pre-Include File -- Global Include Pre/Post by filename

2005-04-05 Thread Peter Beckman
Back in 2000 I remember there being a file that could be created in the
include path that, if existed, would be called and executed before any
other PHP script was executed.  There was also a script that if named
correctly and put in the include path, would execute AFTER the called
script was executed.
Was this depreciated, or does it still exist?  I can't remember what to
call it, and I can't seem to find the right page in the manual.  Any help?
Beckman
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Pre-Include File -- Global Include Pre/Post by filename

2005-04-05 Thread Peter Beckman
Dear Peter --
Had you waited two more minutes to post (after looking for only a paltry 47
minutes), you would have found the auto_prepend_file and auto_append_file
php.ini configuration directives which do what you want.
Though it is a little difficult to find them on the PHP site, and Google
wasn't entirely helpful, they are there for you to enjoy.
Beckman
On Tue, 5 Apr 2005, Peter Beckman wrote:
Back in 2000 I remember there being a file that could be created in the
include path that, if existed, would be called and executed before any
other PHP script was executed.  There was also a script that if named
correctly and put in the include path, would execute AFTER the called
script was executed.
Was this depreciated, or does it still exist?  I can't remember what to
call it, and I can't seem to find the right page in the manual.  Any help?
---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Content Management

2005-03-22 Thread Peter Westergaard
So I was looking at PHP products the other day, and I realized there are a
few areas of web development in which I'm utterly ignorant. The most
important, right now, is Content Management.

(i.e. You design a site so that the client can manage it after you leave,
even if they don't know HTML, and preferably can even farm out
sub-sections of the site to other team members).

I've heard that PHP-Nuke and PostNuke are powerful and free (free is good
here) but fairly complex. I've also seen good reviews of SubDreamer, less
powerful than the *Nukes but also less complicated and easier for clients
to understand.

I'm helping to provide a community website for a condo, with mostly-static
content (regulations, by-laws, forms, etc) and frequent-update content
(committee events, board of directors' meeting minutes, newsletters, home
tips, area news, etc), so my needs aren't very complicated.

Anyone have any practical experience to share?

Apologies if this has been rehearsed a thousand times before, I see
discussions pop up in the archive but they never seem to come to a
concensus so I'm going to risk asking again...

-P


-- 
Peter @ westergaard .ca

A byte walks into a bar and orders a pint. Bartender asks him What's
wrong? Byte says Parity error. Bartender nods and says Yeah, I thought
you looked a bit off.

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



[PHP-DB] Re: Double Inserts

2005-02-02 Thread Peter K. Lee
Hi Shri,

[EMAIL PROTECTED] (PHPDiscuss - PHP Newsgroups and mailing lists) writes:

 Hi, I am new to the mailing list and to PHP / MySQL. I am facing an
 unususal problem. I am trying to insert some data into MySQL DB through
 via Web. The code is executed OK - no errors but the same record gets
 inserted TWICE. I have checked the code and simplified it as much as
 possible and tried test scripts with same results. I have also tried
 statements to echo messages to ensure the code is not executed twice. 
 
 It happens with IE as wells as Mozilla so I don't think it is a browser
 issue. The only clue is that it does not seem to happen on a slower
 machine (Laptop). The configurations, versions etc are identical - Apache
 2.0.49, MySQL 4.1.6-gamma-nt, PHP 5.0.2
 
 Has anyone faced this and found a solution? Please help.
 
 Shri

I had a similar problem.  It was unrelated to PHP or MySQL.  Are you using
javascript as part of the page?  In particular, attaching an event handler
to onSubmit event?

I had an onSubmit event handler that called this.submit() as part of the
routine.  I didn't realize that caused the submit to happen twice.  The
double insert has vanished since.

See if your page is getting posted twice for whatever reason.

-Peter

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



RE: [PHP-DB] last record

2005-01-24 Thread Peter Lovatt
hi

using mysql as you describe is probably the most elegant and efficient way
to do it

is there a reason for asking php to do it?

Peter


 -Original Message-
 From: neil [mailto:[EMAIL PROTECTED]
 Sent: 25 January 2005 03:12
 To: php-db@lists.php.net
 Subject: [PHP-DB] last record


 Apart from the obvious of reversing the sort order in a select
 statement and
 then picking off the first record

 eg. select * from blah where somefield like '%something%' order by
 someotherfield desc limit 0,1

 is there any way in php rather than sql to pick the last record
 in a record
 set?

 Thanks

 Neil

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


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



RE: [PHP-DB] i am lost (php warning)

2005-01-18 Thread Peter Lovatt
Hi


it means that the query did not  produce a result - usually this is because
of a problem with the query.

$sql_query = mysql_query(SELECT * FROM cm_customer WHERE emial='$user');

I am guessing you misspelt email and this should be

$sql_query = mysql_query(SELECT * FROM cm_customer WHERE email='$user');


if you add an error trap it makes this knd of thing easier to spot

$sql_query = mysql_query(SELECT * FROM cm_customer WHERE email='$user') or
die(mysql_error());


HTH

Peter











 -Original Message-
 From: Earl Clare [mailto:[EMAIL PROTECTED]
 Sent: 18 January 2005 06:59
 To: php-db@lists.php.net
 Subject: [PHP-DB] i am lost (php warning)
 Importance: High


 Hi ya'll,



 I am lost as to why I am getting this error in my script. Can
 anyone kindly
 explain why this is so.



 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
 resource in /home/cm/public_html/cell/login.php



 --
 --
 ---

   My script

 --
 --
 ---





 if($_POST['submit'] == 'Log In')

 {

 $user=$_POST[email];

 $pass=$_POST[pass];

 $sql_query = mysql_query(SELECT * FROM cm_customer WHERE
 emial='$user');

 $sql_query = mysql_num_rows($sql_query);



 if (($sql_query) 0)

 {

 $valid = $user;

 session_start();

 session_register(valid);

 }

 }



   if (session_is_registered(reg))

   {

   echo ok;

   }



   else

   {

  echo sorry;

   }





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



RE: [PHP-DB] Security Question

2005-01-17 Thread Peter Lovatt
Hi

The page/form will be requested over a non secure connection. When the form is 
submitted the browser establishes a secure connection to the server and then 
sends the data, so the data is sent securely.

Peter




 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: 17 January 2005 03:47
 To: php-db@lists.php.net
 Subject: Re: [PHP-DB] Security Question
 
 
 But what I'm saying is that if you're submitting a form from an unsecured 
 page, to a script on a secure server, the data will still be encrypted. 
 Anyone know this for sure to be correct? It sure makes sense this way. 
 
 
 On Sunday 16 January 2005 07:27 pm, Peter Lovatt wrote:
  Hi
 
  It is better from a security point of view to have a secure login. The
  secure server encrypts the data between the browser and the 
 server, making
  it impossible to read on its journey from you to the server.
 
  However whether it is a major security  problem is another question. To
  view the traffic somebody must have access to the servers that 
 route your
  request, which isn't easy. They then have to spot your traffic 
 amongst all
  the other web traffic.
 
  If it is the login for your Swiss bank account where you hid the million
  you made without declaring tax then it should be secure - no 
 question. On
  the other hand if it is just to login to see when your books will be
  delivered, with no sensitive financial information then the 
 risk is smaller
  and it is unlikely that anyone is trying too hard to get your 
 login, so an
  insecure login carries less risk.
 
  You could always host the login page on a non secure server but post the
  form to a secure server.
 
  Peter
 
   -Original Message-
   From: Micah Stevens [mailto:[EMAIL PROTECTED]
   Sent: 17 January 2005 02:46
   To: php-db@lists.php.net
   Subject: Re: [PHP-DB] Security Question
  
  
  
   If it submits to a secure server the form data will be 
 encrypted before
   transmission I believe. At least that's my understanding, and
   that seems to
   be how ebay does it for example. Once you log-in, it submits 
 to a secure
   page.
  
   -Micah
  
   On Sunday 16 January 2005 06:38 pm, Chris Payne wrote:
Hi everyone,
   
   
   
I have a security question, I want to see if I am right or
  
   wrong.  I have
  
programmed a system with PHP and MySQL, the main system resides
  
   on a secure
  
server, but the client wants the login page on a NON-Secure 
 server for
marketing purposes.  Am I the only one who thinks this is a
  
   major security
  
concern?
   
   
   
Chris
  
   --
   PHP Database Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



RE: [PHP-DB] Security Question

2005-01-16 Thread Peter Lovatt
Hi

It is better from a security point of view to have a secure login. The secure 
server encrypts the data between the browser and the server, making it 
impossible to read on its journey from you to the server.

However whether it is a major security  problem is another question. To view 
the traffic somebody must have access to the servers that route your request, 
which isn't easy. They then have to spot your traffic amongst all the other web 
traffic.

If it is the login for your Swiss bank account where you hid the million you 
made without declaring tax then it should be secure - no question. On the other 
hand if it is just to login to see when your books will be delivered, with no 
sensitive financial information then the risk is smaller and it is unlikely 
that anyone is trying too hard to get your login, so an insecure login carries 
less risk. 

You could always host the login page on a non secure server but post the form 
to a secure server.

Peter








 -Original Message-
 From: Micah Stevens [mailto:[EMAIL PROTECTED]
 Sent: 17 January 2005 02:46
 To: php-db@lists.php.net
 Subject: Re: [PHP-DB] Security Question
 
 
 
 If it submits to a secure server the form data will be encrypted before 
 transmission I believe. At least that's my understanding, and 
 that seems to 
 be how ebay does it for example. Once you log-in, it submits to a secure 
 page. 
 
 -Micah 
 
 
 On Sunday 16 January 2005 06:38 pm, Chris Payne wrote:
  Hi everyone,
 
 
 
  I have a security question, I want to see if I am right or 
 wrong.  I have
  programmed a system with PHP and MySQL, the main system resides 
 on a secure
  server, but the client wants the login page on a NON-Secure server for
  marketing purposes.  Am I the only one who thinks this is a 
 major security
  concern?
 
 
 
  Chris
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



RE: [PHP-DB] Help in learning PHP and MySQL

2004-12-31 Thread Peter Lovatt
Hi

from php 5 onwards mysql is not enabled by default

http://www.php.net/manual/en/ref.mysql.php


Note: Windows users will need to enable php_mysql.dll inside of php.ini and
either copy libmysql.dll into the Windows system directory, or make it
available to the PATH.

from memory...
(To enable it, edit php.ini - find the reference to php_mysql.dll and remove
the ; which comments it out )

Peter




 -Original Message-
 From: Novice Learner [mailto:[EMAIL PROTECTED]
 Sent: 31 December 2004 03:35
 To: php-db@lists.php.net
 Subject: [PHP-DB] Help in learning PHP and MySQL


 I apologize if this is a very basic question.

 I just started learing PHP and MySQL, I am reading PHP and
 MySQL by Larry Ullman, I also have access to PHP 5 by Julie
 Meloni. I reached Chapter 6 of Ullman's book and got stuck.

 I have the following code:

 ?php
 //This file contains the database access information. This file
 also establishes a connection
 //to MYSQL and selects the database.
 //Set the database access information as constants
 define ('DB_USER', 'masud');
 define ('DB_PASSWORD', 'masud');
 define ('DB_HOST', 'localhost');
 define ('DB_NAME', 'masud');
 //Make the connection and then select the database
 $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
 mysql_select_db(DB_NAME);
 ?

 I have a normal MySQL user as masud, whose password is also
 masud and a database also called masud. All this for learning purpose.

 I get the following error message:

 Fatal error: Call to undefined function mysql_connect() in
 C:\Program Files\Apache
 Group\Apache2\htdocs\CTA\mysql_connect.php on line 13

 The books says:
 If you receive an error that claims mysql_connect() is an
 undefined function, it means that PHP has not been compiled with
 MySQL support.

 I have been running a test script with ? phpinfo(); ? and I get
 the results successfully.

 I am running Windows XP with Apache 2 server and PHP5 5.0.3

 I would appreciate if you could help me in any way, including
 pointing me to resources that can help get going.

 Thank you,

 Masud



 -
 Do you Yahoo!?
  Read only the mail you want - Yahoo! Mail SpamGuard.

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



Re: [PHP-DB] is this a problem ?

2004-12-28 Thread Peter Jay Salzman
On Tue 28 Dec 04, 11:44 AM, Miles Thompson [EMAIL PROTECTED] said:
 
 At 09:25 AM 12/28/2004, amol patil wrote:
  hallo,
  
  i have changed file   signup1.php with login1.php, in action fied of form
  
  form name=form1 method=POST action=--
  
  and saved .
  
  but when i run this file and click on submit button,  it still shows old 
  sighnup1.php. and data is also not entering in database. while it data was 
  entering in databse  before this. but not now with this change.
  
  no error shown. only shows previous page and no data entry


 There are scores of examples / tutorials on this. Google turned up 6,070 
 hits on this expression:
 
 add user php mysql example
 
 Here's one of them, although it assumes register globals is on
 
 http://www.php-scripts.com/php_diary/072000.php3
 
 Why don't you pick one, work with it and adapt it to your needs.
 
 However, why is your form's action parameter set to a string of hyphens?
 
 Regards - Miles Thompson
 

Agreed.  Also, you'd get *much* better replies to your request for help if
you read this:

   http://www.catb.org/~esr/faqs/smart-questions.html
 
Sometimes it's very difficult to ask a good question, and I think esr breaks
his own rule (volume is not precision), but he says all the right things,
and has some excellent advice.

This isn't meant to be a put-down or a joke.  Most people think that asking
a question absolves them of thinking.  Like a quick-fix.  On the contrary,
asking a good question can be a lot of work.

Respectfully,
Pete

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



Re: [PHP-DB] Site optimization

2004-12-28 Thread Peter Jay Salzman
On Tue 28 Dec 04, 12:11 PM, Joseph Crawford [EMAIL PROTECTED] said:
 i was wondering this as well :D
 
 are there any tools out there to simulate high traffic on your web
 server say where you specify how many users hit the site at one time
 and the tool actually hits your server that many times?
 
Is this what you're looking for?

http://www.linuxjournal.com/article/6691

Pete

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



[PHP-DB] Update keeps failing with php/sqlite

2004-12-27 Thread Peter Jay Salzman
Hi all,

I made a toy database.  Two tables are students (a collection of student
info) and message (private messages I want individual students to read).
The message table is indexed by a student's social security number.

student
   last, first, ssn, address, city, state, zip, email

message
   msg1, ssn


I'm trying to update msg1, unsuccessfully.  Everything *seems* to go
perfectly.  The $_POST variables exist and hold what I think they should
hold, the SQL looks OK.  I checked the sqlite website, and UPDATE is
indeed supported.  I've been scratching my head a lot over this one:


The given code is (note My_Header() and My_Footer() just interject a little
HTML, like html and the like):




// We picked the class and student.  Now display the current message.
//
if ( isset($_REQUEST['action'])  $_REQUEST['action'] == 'editmsg' )
{
$handle = sqlite_open($_SESSION['dbfile'])
or die(Could not open database.);

$query = SELECT msg1 FROM message  .
WHERE ssn = ' . sqlite_escape_string($_POST['ssn']) . ';

$result = sqlite_query( $handle, $query );

if ( sqlite_num_rows($result)  0 )
$msg = sqlite_fetch_single($result);
else
$msg = '';


My_Header(Messages);

?
form method=post action=? echo $_SERVER['PHP_SELF']; 
??action=submitedit
textarea name=msg cols=40 rows=8
? echo +$msg+ ?/textarea
pinput type=hidden name=ssn value=? echo $_POST['ssn'] 
?/p
pinput type=submit value=Edit/p
/form

?

My_Footer();

exit(0);
}



// If we're here, it's because we want to update the message in the
// database.  This performs the SQL using UPDATE.
//
if ( isset($_REQUEST['action'])  $_REQUEST['action'] == 'submitedit' )
{

$handle = sqlite_open($_SESSION['dbfile'])
or die('Error in query: ' .
sqlite_error_string(sqlite_last_error($handle)));

$query = UPDATE message  .
SET msg1 = ' . sqlite_escape_string($_POST['msg']) . '  .
WHERE ssn = ' . sqlite_escape_string($_POST['ssn']) . ';


sqlite_query($handle, $query)
or die('Error in query: ' .
sqlite_error_string(sqlite_last_error($handle)));

Header(Location:  . $_SERVER['PHP_SELF'] . ?action=chose);
exit(0);
}

?



Anything wrong with this code?  I've tried to write as defensively as I can.

Thanks!
Pete

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



Re: [PHP-DB] How to process a query form with CHECKBOX Please help

2004-12-27 Thread Peter Jay Salzman
On Mon 27 Dec 04,  5:22 PM, S Kumar [EMAIL PROTECTED] said:
 Dear group, 
  I am a novice programmer started doing php to process
 a query form of my patients.  
 
 I have a database and one table in it deals with my
 patient information.  Depending on their condition I
 divided their age groups into 3 categories. In my
 database a table patient_data has a column age_group
 and a patient can be any one of young, middle or old
 category.   
 Now the possibility is that a user can selecct 1 or 2
 or all three options.
 
 In the query form, I gave the option for a user as a
 check box. The piece of html code is as below:
 
 DIVAge group/DIV
 DIVYounginput type=checkbox name=
 value=/DIV
 DIVMiddleinput type=checkbox name=
 value=/DIV
 DIVOldinput type=checkbox name= value=/DIV
 
 Problem:
 I want to capture the user options and create an SQL
 statement:
 
 Select age_group from patient_data where age_group =
 young and old ; 
 
 
 I am truly stuck here. Can any one please help me out
 to pass this situation. 
 
 Thank you in advance.
 
 Kumar. 
 


It seems as though the SQL itself is pretty straight forward.  The where
clause would be generated from a conditional based on what values are true.

Exactly what are you having difficulty with?

Pete

PS- How can a single patient be young, middle, and old at the same time?  
Are you
   a psychologist?

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



Re: [PHP-DB] How to process a query form with CHECKBOX Please help

2004-12-27 Thread Peter Jay Salzman
On Mon 27 Dec 04,  9:22 PM, p p said:
  
  Select age_group from patient_data where age_group =
  young and old ; 
  
  
  I am truly stuck here. Can any one please help me out
  to pass this situation. 
  
  Thank you in advance.
  
  Kumar. 
  
 PS- How can a single patient be young, middle, and old at the same
 time?  Are you a psychologist?

Sorry.  There should have been a smiley :-) after that sentence.

Pete

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



Re: [PHP-DB] How to process a query form with CHECKBOX Please help

2004-12-27 Thread Peter Jay Salzman
On Mon 27 Dec 04,  8:48 PM, S Kumar [EMAIL PROTECTED] said:
 Hello Pete:
 
 However, in the case of checkboxes, I do not know how
 to make variables out of them depensing on what user
 selects.  Say whatever user cheks in the checkbox,
 that variable has to be searched in TABLE-C and
 various other columns in that table.  I am totally
 clueless how  I can capture what user checks as a
 variable and incorporate into the SQL statement. 
 
Hi Kumar,

I've never played with databases before 3 or 4 days ago, and maybe played
around with HTML forms a couple of times in my life.  I'm still learning the
basics of SQL, so if you don't know something about SQL, I almost certainly
don't know it!

However, if all you need to know is how to access checkboxes in PHP... that
I've played around with.  I wrote a sample program, check.php.

Sorry for the painfully obvious comments, but I wrote them for me just as
much as for you.  :)  I tried to write it as defensively as I know how, but
like I said, I'm just learning this stuff myself.  Hope it's OK!   :)

You should be able to generalize this to more than one set of checkboxes,
but if not, let me know and I'll whip up another sample program.  Basically,
all the magic is in the name= parameter in the input tag.  Use the same
name for things that related options.  Use different names for different
groups of checkboxes (but put them all within the same form tag.

Note: I just realized that I used a for loop.  I recall reading somewhere
that foreach is more efficient than for, so that may be one way to improve
this.  Anyhow, here it is.

HTH,
Pete




!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN';
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;

html
head
titleCheckboxes With PHP Example/title
/head


body

form action=? echo $_SERVER['PHP_SELF'] ??action=posted method=post
input type=checkbox name=mycheckbox[] value=? echo date(l); 
?/Choice 0br/
input type=checkbox name=mycheckbox[] value=hello/Choice 1br/
input type=checkbox name=mycheckbox[] value=2.3827/Choice 2br/
pinput type=submit/p
/form

?

// This checks to see if the submit button was hit.
//
if ( ! isset($_REQUEST['action']) )
exit(0);


// The checkbox group with name foobar[] can be accessed
// by $_POST['foobar'].  As always, $_POST is an array, so
// the thing that we assign $_POST to is also an array, which
// can be counted, indexed, foreach'ed, etc.
//
// If nothing was checked, the $_POST['mycheckbox'] array doesn't
// exist, which will print a warning if we set E_ALL on.  So let's
// check to see if it exists first, and if not, tell the user to
// check something.
//
if ( ! isset($_POST['mycheckbox']) )
die(I'm going to sit back and wait until you check something!);



$mycheckbox = $_POST['mycheckbox'];

echo 'ul';

for ($i=0; $i  count($mycheckbox); $i++)
{ 

// This shows you how to access checkboxes in PHP.  Now that you have a
// list of all the stuff that's been checked, you can use a whole bunch
// of conditional statements to form your complex SQL.
//
echo limycheckbox[$i]: $mycheckbox[$i]/li; 

}

echo '/ul';


?

/body
/html

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



[PHP-DB] Undefined indicies

2004-12-26 Thread Peter Jay Salzman
Slightly off topic, I apologise.

Total newbie.  In many php DB tutorials I've seen, it's recommended to set
register_globals off, and error reporting to E_ALL.

When I looked at my system, register_globals was enabled and error reporting
was set to E_FATAL.  I changed them to the suggested values (off and E_ALL),
and all hell broke loose.  Clearly, I must not be very good at PHP yet.  ;)

First question:

register_globals is a matter of security, so that's definitely valuable to
turn off.  Is setting error reporting really useful if my aim is to become a
better PHP programmer?

I'm thinking along the lines of lint/splint, where this line of code in C:

   printf(hello world\n);

generates a useless warning because I'm not using printf()'s return value.
I'm wondering whether it's useful for a scripting language, like PHP, to
warn me when I use code like:


   if ( $_REQUEST['action'] == 'foo' )
  do_something;


when I don't access the URL with a ?action=foobar type request.

Should I change error reporting back to E_FATAL or is being this
compulsive about warnings good for me (and my security)?



Second question:

If being compulsive is good for me, what's the best way of handling
something like above?   From browsing php.net, I've thought of a few ways,
like a controlled suspension of compulsion:


   if ( @ $_REQUEST['action'] == 'foo' )
  do_something;

or, lord forbid:

   if ( isset($_REQUEST['action'])  $_REQUEST['action'] == 'foo' )
  do_something;

and also variations on a theme:

   if ( array_key_exists('action', $_REQUEST )
  $action = $_REQUEST['action'];

   if ( isset($action) )
  do_something;


Personal preference must play into this, but I'm wondering what more
experienced PHP programmers do.  My code is riddled with this kind of thing.

Thanks (and sorry for the long winded / slightly off-topic post!)

Pete

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



[PHP-DB] php4 + sqlite - quoting stuff

2004-12-25 Thread Peter Jay Salzman
Hi all,

I'm a kinda-sorta newbie to php -- I basically just futz around with it
because it's pretty cool.

However, I'm brand spanking new to databases.  Never did anything with them.
I taught myself a little SQL because it looked fun to learn, but I just
thumbed through some books.  I never really used a database in earnest.  Too
difficult to set up, and my dual Celeron 333 is underpowered as it is
without having an extra daemon running.

Yesterday, I taught myself sqlite + perl, and that was a LOT of fun.  But
then I remembered I hate using perl for CGI, so today I started messing
around with sqlite for php4.

There's something I'm not groking about php's syntax.  When I look at how
you're supposed to quote stuff in sqlite for php4:

sqlite_query( $handle, 
INSERT INTO course VALUES (
' . sqlite_escape_string($termcode). ',
' . sqlite_escape_string($semester). ',
' . sqlite_escape_string($course)  . ',
' . sqlite_escape_string($course_desc) . ',
' . sqlite_escape_string($college) . ',
' . sqlite_escape_string($reference)   . '
)
) or die(Error bravo in query:  .
sqlite_error_string(sqlite_last_error($handle)));

it makes me want to cry.  Php should be prettier than Perl, not uglier.  We
have single quotes, double quotes and a string quote function.

How am I supposed to parse this?  What's the purpose for all this quoting?

And is there a _nicer_ way of doing this?

Thanks!
Pete

PS- I don't want to count out the possibility that some of my values have
quote characters in them.

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



RE: [PHP-DB] Re: HTTP Auth for PHPMyAdmin

2004-12-22 Thread Peter Lovatt
set auth type to cookies

Peter

 -Original Message-
 From: Mark Benson [mailto:[EMAIL PROTECTED]
 Sent: 22 December 2004 10:55
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: HTTP Auth for PHPMyAdmin
 
 
 Martin Norland wrote:
 
 What do you mean proper HTTP authorization for PHPMyAdmin - do you want
 it to log you in automatically, or do you want to use .htaccess to
 protect your PHPMyAdmin scripts?
 
 By your statement of config file, and talking about PHPMyAdmin - I'm
 assuming that you've configured it to automatically log you in - in
 which case I would suggest you verify you can login with the same exact
 paramters on its normal login, as well as confirming that the parameters
 are indeed set when it attempts to check them.
 
 Sorry I was being chased out of the building at the end of the 
 day when I was writing that e-mail :)
 
 What I meant was I want to setup phpMyAdmin so that a login is 
 required when you access the pages (i.e. you must enter a u/n and 
 pwd in a dialog).
 Currently my config.inc.php is set so that the 
 '$cfg['Servers'][$i]['auth_type'] = 'config'; and I supply 
 the MySQL user and pwd in the config.inc.php and it connects 
 automatically. This is not ideal as I'd like to prevent others 
 accessing it, for security and integrity reasons.
 
 If I set the config.inc.php value to 
 '$cfg['Servers'][$i]['auth_type'] = 'http';' then it will 
 show a login dialog on connection but any u/n and pwd I try 
 (based on the MySQL grant tables) is rejected.
 
 What I need to know is what is the best way to limit access to 
 the pages, do I ignore the config.inc.php and setup some other 
 system or can i use the grant tables from my MySQL server?
 
 Ideally I would want to log into the MySQL server as either my 
 normal 'dbadmin' user OR 'root' as only 'root' has alteration 
 rights on the grant tables so stuff that is outside the auspices 
 of normal admin is easier to carry out (i.e. doesn't involve me 
 hacking the config.inc.php all the time).
 
 -- 
 Mark Benson
 
 http://homepage.mac.com/markbenson
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



RE: [PHP-DB] password encryption

2004-11-18 Thread peter
Quoting Gryffyn, Trevor [EMAIL PROTECTED]:

 If you want to be cheesy, you can also use something like an MD5 has on
 dog and get whatever it gets Then every time someone enters dog
 it always ends up with the same MD5 hash.

How is using MD5 cheesy?  I've implemented exactly that solution a number of
times.  Admittedly, only for a very small site, mainly as the 'site content
update' password.

-P

ps. and on another note, why am I in the list of direct addressees here?

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



[PHP-DB] PHP on an Windows intranet with MSOffice-like templates

2004-11-16 Thread peter
I don't even know if this is possible, or if I'll have to go the route of .NET
development to get this sort of functionality (I'm sure it's possible if I jump
through enough hoops).

But here's what I'm trying to accomplish...
- users are all on a local intranet with access to a shared drive (no prob)
- users navigate a PHP-MySQL application to select records from a database  (no
prob)
- users are able to click a link which will launch some sort of document (they
have Office, but if something like PDF is available on a Windows platform,
great) where a document template is fetched and updated with information from
the selected record.(This is the part I don't understand how to do).

An example... user wants to be able to print one of a variety of letters to
physically mail to a customer, customized with the customer's account info. 
(You know:  Dear [first name] [last name], ... Your account [account_id] ... is
30 days past due... etc )

This way, management can update the template and not have me re-work the code to
have it work...

Is such a thing possible on a windows PHP platform?  Can someone point me to
somewhere I can learn more about it?

Thanks much,
-P

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



RE: [PHP-DB] Problem with script

2004-11-02 Thread Peter Lovatt

Try echoing the actual query being run. It will give you more info to work
with.

Peter




 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]
 Sent: 02 November 2004 16:42
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Problem with script


 Hi all, greetings from Phoenix, Arizona!
 I'm having a problem with a PHP script and the database it manages.
 I'm having his error message:

 Query failed: You have an error in your SQL syntax. Check the manual that
 corresponds to your MySQL server version for the right syntax to use near
 't read card','1099413551')' at line 1

 I don't know what is happening, usually the database works well but
 sometimes this strange error appears. I'm sending you the scripts in where
 I think the error could be.

 Any suggestion or comment will be very appreciated.

 Thanks

 Renato

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



RE: [PHP-DB] PHP versions - Development server live server...

2004-10-14 Thread Peter Borcherds
I don't recall installing any optimising or encrypting extensions??  Are
they perhaps installed with mySQL?  How do I reinstall them, that is
assuming I need them?

-Original Message-
From: M Saleh EG [mailto:[EMAIL PROTECTED]
Sent: 14 October 2004 03:24
To: Peter Borcherds
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] PHP versions - Development server  live server...


Seems that ur optimizing and encrypting extensions are not loaded properly.
That's what it means.
Okay, It might mean that you're old PHP's PHP.ini is still there and
the new one is using it while it doesnt have the extensions files.
check if those files are there...

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



[PHP-DB] PHP versions - Development server live server...

2004-10-13 Thread Peter Borcherds
Hi all,

First of all, apologies if this is posted more than once...I'm having 
trouble with my newsreader!!

I am running Win XP Pro as my development machine - at present I have PHP
4.3.4 installed on this machine.  My question is...my two web hosts for my
PHP hosting have PHP 4.3.2  PHP 4.3.4 installed respectively...what happens
if I install the latest production release of PHP, namely 4.3.9, on my Win
XP Pro machine and then develop using that?  Will I be able to use pages
coded on my dev machine on the live servers, even though the servers are
running older versions of PHP?  What do I need to be looking out for with
regard to conflicts?

Thanks!

Peter

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



RE: [PHP-DB] PHP versions - Development server live server...

2004-10-13 Thread Peter Borcherds
Hi Robby,

Thanks for the swift reply!  Okay, so it should be fine to install the 4.3.9
version then - okay...now I assume I should hold-off on the 5.0.2 release
then...?

-Original Message-
From: Robby Russell [mailto:[EMAIL PROTECTED]
Sent: 13 October 2004 22:01
To: Peter Borcherds
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] PHP versions - Development server  live server...

Shouldn't cause any major issue. 4.3.x changes are typically bug fixes.
So, if anything, you'll see a bug on the live servers that was fixed in
your version, but most bugs are not so easy to produce.

-Robby

--

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



Re: [PHP-DB] Short Names

2004-09-25 Thread Peter Ellis
IMHO, no -- it makes the code more readable.  I'd also recommend making
sure that variable names match their purpose (so, for instance, if you
have a variable that contains a mailing address, use $mailing_addr, or
if you have a variable that contains an array of recipes, use
$arr_recipes).  The more you can make your code readable, the better.

Always keep in mind the other people that may read your code -- this, in
general, means commenting and using good sense in variable names.  It'll
help you later for when you haven't touched the code in a year or two
and need to know what you wrote and why...

Hope this helps.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Sat, 2004-09-25 at 14:23 -0700, Cole S. Ashcraft wrote:
 Is it considered bad / sloppy to define the short names of varibales at 
 the beginning of your code so you don't have to type out 
 $_REQUEST[variable] or $HTTP_REQUEST_VARS[variable]?
 
 Cole
 

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



RE: [PHP-DB] Newbie Question - mysql_select_db fails with access denied.

2004-09-24 Thread Peter Lovatt
Hi

try $db = mysql_connect(localhost, myuser,mypassword) - without it  you are not  
submitting a password 

Peter

 -Original Message-
 From: Christian Schlaefcke [mailto:[EMAIL PROTECTED]
 Sent: 24 September 2004 13:31
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Newbie Question - mysql_select_db fails with access
 denied.
 
 
 Hi Folks,
 
 I want to do something like the following:
 $db = mysql_connect(localhost, myuser) or die(Connect failed :  .
 mysql_error());
 
 mysql_select_db(mydb,$db) or die(SELECT_DB failed :  . mysql_error
 ());
 
 $result = mysql_query(SELECT * FROM mytable, $db) or die(Query
 failed :  . mysql_error());
 
 The script does not proceed beyond the mysql_select_db line. I get
 this error:
 SELECT_DB failed: Access denied for user ''@'localhost' to database
 'mydb'
 
 What happened to the user information. I have granted all neccessary
 rights to myuser. But it seems that its even not caring about the
 user.
 
 I have MySQL 4.1.4 and PHP 4.3.8-2.1 on a Fedore Core 2 System  running.
 
 Thanks  Regards,
 
 Chris
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP-DB] Please help

2004-09-08 Thread Peter Ellis
What are the variables $sql and $sql_ext set to?  The query format is
fine.  It's probably in your variables.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Wed, 2004-09-08 at 12:29 -0700, Stuart Felenstein wrote:
 I'm using a product called dbqwiksite pro.  PHP
 generator for PHP - MySQL 
 
 The code seems to be working fine except in my search
 page where I receive an invalid query
 
 $result = mysql_query($sql .   . $sql_ext .  limit
 0,1)
 or die(Invalid query);
 
 This is the place I where the code is taking the die
 path.
 I'm guessing something belongs between the quotation
 marks , just not sure.
 
 Anyone ?
 
 Thank you
 Stuart

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



Re: [PHP-DB] error of check box form

2004-09-08 Thread Peter Ellis
In addition, please send your messages once and only once.  I have two
copies of the same e-mail, both sent to the list successfully with two
different replies to both messages.  You're more likely to get help if
you post and wait for a reply to your original message.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Wed, 2004-09-08 at 05:53 -0400, [EMAIL PROTECTED] wrote:
 Dear friends,
 
 
 Any guidance to the error , please.
 Resubmitting,
 --
 ---
 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in 
 C:\HOME\doctorbush\check.php on line 11
 
 Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting 
 T_STRING or T_VARIABLE or T_NUM_STRING in C:\HOME\doctorbush\check.php on line 73
 
 --
 script code
 -
 ?php
 
 // example code for checkbox.txt
 // confirmed working: Friday, March 07, 2003
 
 // Configuration information for connecting to database
 // Contains $db_name, $db_user, $db_pass, $db_host
 // for connection.
 
 // Enter your database host name here.
 $db_host = \localhost\;
 // Enter your database password here.
 $db_pass = \\;
 // Enter your database user name here.
 $db_user = \\;
 // Enter the name of your database here.
 $db_name = \\;
 
 // Connect to database
   $db_conn = @mysql_pconnect($db_host, $db_user, $db_pass);
 
 // Check for database unavailable 
 if (!$db_conn)
 {
 print \ERROR - failed to create connection: \ . 
 mysql_error();
 
 }
 
 
 function make_item_control($value,$title) { 
 $content = 'tr class=\tabletext\tdinput type=\checkbox\ 
 name=\item[]\ value=\'.$value.'\ /'.$title.'/td';
 
 return $content;
 }
 
 if($p_delete_checked) {
 // Process items
 // We substract one from the count because a for loop executes 
 once
 
 // before incrementing.
 $n = count($item)-1;
 for($i = 0; $i = $n; $i++)
 {
 $sql = \DELETE FROM note WHERE note_id = $item[$i];\;
 $result = mysql_db_query($db_name,$sql);
 
 if (!$result) {
 print ' ERROR - Delete note query failed: ' 
 .mysql_error();
 
 }
 
 }
 } else {
 // list items
 
 // database query here
 
 $sql = \SELECT note_id,film_id,LEFT(text,32) AS item_name FROM 
 note ORDER BY film_id ASC;\;
 
 $result = mysql_db_query($db_name,$sql);
 
 if (!$result || mysql_num_rows($result)  1) {
 print ' ERROR - Select note query failed: ' 
 .mysql_error();
 
 }
 
 print 'form action='. $_SERVER['PHP_SELF'] .'';
 print 'table';
 while($row = mysql_fetch_array($result)) {
 print make_item_control($row[note_id],$row[item_name]);
 }
 print 'tr class=\tabletext\
 td
 input type=\Submit\ name=p_delete_checked value=\Delete 
 Checked\ /
 
 /tr';
 print '/table';
 print '/form';
 
 }
 
 
 
 ?

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



RE: [PHP-DB] Please help

2004-09-08 Thread Peter Lovatt
HI

try 

 $result = mysql_query($sql .   . $sql_ext .  limit 0,1)
 or die(Invalid query.mysql_error());

which will give more detail on the error.

HTH

Peter

 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 08 September 2004 20:29
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Please help
 
 
 I'm using a product called dbqwiksite pro.  PHP
 generator for PHP - MySQL 
 
 The code seems to be working fine except in my search
 page where I receive an invalid query
 
 $result = mysql_query($sql .   . $sql_ext .  limit
 0,1)
 or die(Invalid query);
 
 This is the place I where the code is taking the die
 path.
 I'm guessing something belongs between the quotation
 marks , just not sure.
 
 Anyone ?
 
 Thank you
 Stuart
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP-DB] error on count()

2004-09-07 Thread Peter Ellis
You need to pass the functions a variable to work with because you've
specified parameters.  Try:

$okuan = orderquantity($una);

Ditto for the other function call.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Tue, 2004-09-07 at 13:09 +0200, Sancerni Veronica wrote:
 hello, this is problably newbie question, but I can not understand why my count() 
 function doesn't work. I need to count how many items has a determinated customer 
 ordered ever.
  
 1. I tired to get the array like this:
  $una = $check[uname];
 function orderquantity ($una) {
   $pss = mysql_query(SELECT OID FROM orders WHERE una = '.trim($una).') or die 
 (mysql_error(Query error on Order search));
   while($pisao=mysql_fetch_array($pss)) {
   return count($pisao);
   }
 }
 $okuan = orderquantity();
  
 2. and like this:
  $una = $check[uname];
 function orderquantity ($una) {
   $pss = mysql_query(SELECT OID FROM orders WHERE una = '.trim($una).') or die 
 (mysql_error(Query error on Order search));
return count($pss);
 }
 okuan = orderquantity();
  
 None of them gave me a valid value, is it because the OID is an int value?
 
   
 -
 Crez gratuitement votre Yahoo! Mail avec 100 Mo de stockage !
 Crez votre Yahoo! Mail
 
 Le nouveau Yahoo! Messenger est arriv ! Dcouvrez toutes les nouveauts pour 
 dialoguer instantanment avec vos amis.Tlchargez GRATUITEMENT ici !

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



Re: [PHP-DB] Building A Web Site Search Engine Using PHP / mySQL

2004-09-07 Thread Peter Ellis
Well, this is from the why reinvent the wheel department -- have you
looked at htdig://?

http://www.htdig.org/

Might save you some work.  Just a thought :)  More constructive replies
regarding actual code are forthcoming, I'm sure.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Tue, 2004-09-07 at 21:10 -0400, Ron Piggott wrote:
 I wanted to also ask about how you would build a web site search engine with
 php and mySQL.
 
 I had thought of setting up a table with a few columns ---
 
 one for the URL of the specific page (This could become a link when a match
 is found for that page)
 second with the page title --- used in displaying the search results
 third with the plain text from the page --- for searching purposes
 
 and then having one line of the table per web page on the site
 
 Then setting up a PHP form that would search the text from the page and make
 some type of matching results page for each entry that found the words the
 user typed in.
 
 Any other thoughts?  There is no compression this way,. but maybe there
 doesn't need to be.  I don't know how to automate populating a table, but I
 could use the cut / paste feature.
 
 Any other thoughts?  I know how to do the above and the PHP commands to
 use --- I wanted to ask before I got started for any tips instead of
 re-starting.
 
 Ron

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



Re: [PHP-DB] php Form Validation help

2004-09-06 Thread Peter Ellis
See below for point-by-point.

...
 
 
 CODE
 
 $state = $_POST['state'];
 
 if ($state = 0) {

= is an assignment operator.  This will always test true, because $state
is set to 0 every time this is called.  You want ==, which is a
comparison operator.

 print 'pPlease select your State/p';
 
 }
 
 /CODE
 



 CODE
 
 $phone = $_POST['p-areacode'] . - . $_POST['p-prefix']. - .
 $_POST['p-suffix'];
 
 /CODE

More like:

$phone = $_[PST[area] . - ..

You get the idea -- dashes need to be surrounded by quotes.

 
 The next question id for both phone number and area code. 
 
  
 
 If I want to validate the zip code and ensure a minimum of X characters in
 the field, numbers only how would I do this?

You can check the string length and see if it's within the bounds you
want.  Look at the Strings section of the PHP manual for the proper
function (str_len, I think).

 
 Would this be somewhat on the right track?
 
 CODE
 
 If ($zip str 5) {
 
 print 'pPlease enter your Zip Code (EX. 77662)/p';
 
 }
 
 /CODE

Nope.  If someone entered 98115, then this would be  5, since there's a
difference of 98110 integers :)

 
 And for the phone number I would assume I could use:
 
 CODE
 
 If ($_POST['p-areacode'] str 3 ) {
 
 print 'pPlease enter your Area Code (EX. 77662)/p';
 
 }
 
 /CODE
 

See comment on string length above.

  
 
 I am still new with PHP, any help would be appreciated. Below is the code I
 have sofar:
 
  


Hope this helps.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

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



Re: [PHP-DB] Re Displaying Text From A Data File

2004-09-04 Thread Peter Ellis
If it were a database, this would make sense.  He's asking about a text-
based file.  This isn't really a database issue -- there's a lot of what
are called fortune scripts out there that do exactly what you want.
Do a search on Google.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Sat, 2004-09-04 at 19:59 +0100, Neil Smith [MVP, Digital media]
wrote:
 It's actually very simple : Just use
 
 SELECT * FROM tbl_name ORDER BY RAND() LIMIT 1
 
 Cheers - Neil
 
 
 At 17:35 04/09/2004 +, you wrote:
 Message-ID: [EMAIL PROTECTED]
 From: Ron Piggott [EMAIL PROTECTED]
 To: PHP DB [EMAIL PROTECTED]
 Date: Sat, 4 Sep 2004 14:00:56 -0400
 MIME-Version: 1.0
 Content-Type: text/plain;
  charset=iso-8859-1
 Content-Transfer-Encoding: 7bit
 Subject: Displaying Text From A Data File
 
 I am still new to PHP and I wanted to ask a question.
 
 I am wanting to create a PHP script to randomly display one of many greeting
 messages on my web site.  I was going to store them in a text based file.  I
 wanted PHP to randomly select one of them and display it each time the
 script was loaded.
 
 I am still new at PHP and I am not sure where to get started.  But I was
 thinking about this and I am sure this has already been done many times ...
 I am not sure where to look on the web.
 
 Can any of you help me get started?
 
 Ron
 
 
 
 CaptionKit http://www.captionkit.com : Production tools
 for accessible subtitled internet media, transcripts
 and searchable video. Supports Real Player, Quicktime
 and Windows Media Player.
 
 VideoChat with friends online, get Freshly Toasted every
 day at http://www.fresh-toast.net : NetMeeting solutions
 for a connected world.
 

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



Re: [PHP-DB] Clicking on the Picture

2004-08-30 Thread Peter Ellis
Yes.  It's called image mapping.  Do a Google search.  This isn't PHP
related.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Tue, 2004-08-31 at 15:07 +1200, Feroz wrote:
 Hi,
 
 I have a Diagram that I need to upload to web page.
 The diagram contains 3 pictures but as one diagram.
 
 Now is it possible to code the pictures in the diagram so its clickable,
 that is when picture one is clicked then it opens a new page.
 
 Regards,
 Feroz
 -
 IT Developer / Systems
 Maxumise (Fiji) Limited
 Level 4, FNPF Place
 Suva,
 Fiji Islands.
 Tel : (679) 330 3137
 Mobile : (679) 995 4250
 
 ~~
 This communication contains information which is confidential
 and may also be privileged. It is for the exclusive use of the intended
 recipient(s). If you are not the intended recipient(s), please note
 that any distribution, copying or use of this communication or the
 information in it is strictly prohibited. If you have received this
 communication in error, please notify the sender immediately
 and then destroy any copies of it.
 ~

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



RE: [PHP-DB] Webpage response to selection $_POST

2004-08-29 Thread Peter Lovatt
Hi

you need to check for $_POST[user1], $_POST[user2] etc - is that what
you are doing?

Your other variables are done as an array - $firstName[$j] etc, should your
check box be

 echo ' tdinput type=checkbox name=user[' . $j . ']
value=1/td' . \n;

(note the [])


Otherwise try vardump($_POST) to see exactly what is being returned.

If this does not fix it try posting the code that handles the response and
we will try and help.

Peter





 -Original Message-
 From: Philip Thompson [mailto:[EMAIL PROTECTED]
 Sent: 30 August 2004 00:12
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Webpage response to selection  $_POST


 Hi all.

 I have a list of users in a database that I would like to show on a
 dynamic webpage. With each of these users that shows up on the page,
 there is going to be a checkbox next to their name so that I can
 perform multiple tasks, such as 'Remove User' or 'Modify Information'.
 I have all of the appropriate information showing up on the page,
 including the checkboxes.

 My question is... if I select a checkbox for a user, the other pages do
 not even recognize that I have selected that checkbox and I am using
 the $_POST method - why is that? I have even attempted to use the
 import_request_variables function - no luck. So, I cannot verify which
 users I want to perform an action on.

 Anyone have any ideas? Snippets of code to follow...

 Thanks in advance,
 ~Philip


 form action=performaction.php method=post
 table
 ?php
 for ($j=0; $j$numRows; $j++) {
  echo 'tr' . \n;
  echo '   tdinput type=checkbox name=user' . $j . '
 value=1/td' . \n;
  echo '   td' . $dbid[$j] . '/td' . \n;
  echo '   td' . $firstName[$j] . '/td' . \n;
  echo '   td' . $lastName[$j] . '/td' . \n;
  echo '   td' . $uid[$j] . '/td' . \n;
  echo '   td' . $username[$j] . '/td' . \n;
  echo '   td' . $classification[$j] . '/td' . \n;
  echo '   /tr' . \n;
 }
 ?
 /table

 input type=submit name=removeuser value=Remove User /
 input type=submit name=modifyclass value=Modify Classification /
 input type=hidden name=beenSubmitted value=1 /
 /form


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



Re: [PHP-DB] Text area

2004-08-26 Thread Peter Ellis
I suspect your return result looks something like

input type=textarea rows=

rather than the full string, as you were expecting.  You do need to
escape quotes, as they are special characters.  Try:

function write_textarea()
 {
  return input type=textarea rows=\5\ cols=\70\ name=\\;
 }

I'm aware of the other replies to this message, but I'm being literal
and assuming you want that exact string returned, regardless of other
alternatives.  HTH.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Tue, 2004-08-24 at 16:43 +0800, Hafidz Abdullah wrote:
 Hi again, everyone.
 
 I also have a problem creating my text area.  I meant to do a text area (measuring 5 
 rows by 70 columns) which accompanies the words: First 50 words are free. 
 Subsequent 50 words or part thereof, $50 will be charged:
 
 function write_textarea()
  {
   return input type=textarea rows=5 cols=70 name=;
  }
  
 Doesn't work. How can I make it work?
 
 Thanks  regards,
 Hafidz

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



RE: [PHP-DB] Help, i'm really desperated

2004-08-25 Thread Peter Lovatt
Hi

php runs as the same user as apache. Depending  on any other security/system
issues you could set apache to run as postgres.

Otherwise why not connect to postgres using the php functions and write the
text file using php?

You might also be able to su to postgres.

HTH

Peter

 -Original Message-
 From: Mário Gamito [mailto:[EMAIL PROTECTED]
 Sent: 25 August 2004 11:09
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Help, i'm really desperated


 Hi,

 I need to run this command inside a PHP (web) script, in order to
 produce an acl list (url_negados.txt) for squid:

 /usr/bin/psql -t knet -c SELECT url_negado from urls_negados 
 /tmp/urls_negados.txt

 I'm using shell_exec to run it.

 Well, so far, so good.
 The problem is that i must run this command as user postgres, otherwise
 it won't work and i can't find a way to do it in PHP :(

 Any ideas would be appreciated.
 I'm realy desperated.

 Warm Regards,
 Mário Gamito

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


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



  1   2   3   4   5   >