Re: [PHP-DB] Picture Upload

2003-03-11 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Dallas Freeman) writes:
 I have asked my host to update the php software, as for now, I need to
 know what the lines for changing the size of a picture is.  I couldn't
 see any command lines for it, unless it is something different, I don't
 know, so could you please show me.

Afaicr, there is an excellent recipe for doing just that in The
Manual, under image functions.

 I also need to know, if there is a possibility that php can change the
 size of an image before it uploads it to the server (so it changes size
 on the end-user's computer  not on the server - that way there would be
 a shorter upload time).

PHP is server side, and can't do anything on the client side (apart
from reading and writing cookies, if the user allows it). I can't see
any other solution to this than to tell the users to resize the images
themselves.


-- 
--Fredrik
Reality is that which, when you stop believing in it, doesn't go
away.
-- Philip K. Dick

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



[PHP-DB] Re: need help with foreach()

2003-03-09 Thread Fredrik de Vibe
[EMAIL PROTECTED] (David Rice) writes:
 Okay, i have two arrays, $tips and $staff
 
 $tips has a key date (which is the date of the first day of the
 week, the second result in the array has the key of the second day of
 the week etc... ) and the value is a floating point decimal.
 
 $staff also has a key date and the value is an integer, the number
 of staff working in one day.
 
 To find out the ammount of tips every staff member is to get we have
 to divide the value of $tips by the value of $staff (when the dates
 are the same)

I guess

while(list($d, $t) = each($tips)){
  $res = $t / $staff[$d];
  // Do what you need with $res ...
}

would do the trick.


-- 
--Fredrik
I cannot and will not cut my conscience to fit this year's fashions.
-- Lillian Hellman

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



Re: [PHP-DB] need help with foreach()

2003-03-09 Thread Fredrik de Vibe
[EMAIL PROTECTED] (David Rice) writes:
 Hey thank's for the ideas but  neither of them work, doh...
 Okay fredrik I know your idea won't work cos list only works with
 numericaly indexed arrays, both the arrays that i am using are indexed
 by date.

You really had me wondering there for a moment. I've done this dozens
of times and list() does work with other than numerical values.

 (it produces a parse error when run)

Ok, I hadn't tested the code. For some reason you have to group $t /
$staff[$d] in parantheses, why I really don't know, it shouldn't be
necessary.

 =
 while(list($d, $t) = each($tips)){
   $res = ($t / $staff[$d]);
  ^   ^
   // Do what you need with $res ...
 }
 =

The code below is tested and works.
---
$tips = array(foo = bar,
  bar = foo);

$staff = array(foo = foobar,
   bar = barfoo);

while(list($d, $t) = each($tips)){
  printf(%s - %s - %sbr\n, $d, $t, $staff[$d]);
}


-- 
--Fredrik
New systems generate new problems.

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



[PHP-DB] Re: explode string variable

2003-03-08 Thread Fredrik de Vibe
[EMAIL PROTECTED] (André Sannerholt) writes:
 Does anybody know how to stop an explosion of a string: Let me explain:
 
 $variable_aray=explode('-', $variable);
 
 I want the variable to be devided in only two other ones! If for example:
 
 $variable=Willy-Brandt-Platz-5
 
 I want to have an array that looks like this:
 
 $variable_array[0] should be Willy
 $variable_array[1] should be Brandt-Platz

I guess you could use the proper regexp functions, like e.g.

  preg_match(/^(\w+)-(.*?)-\d/, $variable, $matches)

then $matches[1] and $matches[2] should (haven't tested) contain what
you want...

-- 
--Fredrik
My opinions may have changed, but not the fact that I am right.

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



[PHP-DB] Re: file save

2003-03-06 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Ryan Holowaychuk) writes:
 I am saving some data to a text file and what I want to do is have each
 line of data collected to be on its own line.
 
 What I am collecting is a roster (no, name, grade) so there is 10-15
 people on a roster, and now when it saves it saves to one line.

Ehm.. add a newline ('\n') at appropriate places?


-- 
--Fredrik
A cynic is a person searching for an honest man, with a stolen
lantern.
-- Edgar A. Shoaff

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



[PHP-DB] Re: Update MD5 field

2003-03-03 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Dani Matielo) writes:
 my problem is the following: I just imported a csv file to a MySQL database
 that contains name and email fields. It has about 9k lines on it and I need
 a new field that orinally didn't exist called code thats suposed to be
 
 MD5(name.email)
 
 I know how to do this for new data, but I don't know how to update all the
 old ones I already have there.

If I understand you correctly, this is probably something like what
you want to do:

ALTER TABLE foo ADD bar VARCHAR(20);

(don't know how long the field needs to be).

UPDATE foo SET bar = MD5(baz);


-- 
--Fredrik
Spare no expense to save money on this one.
-- Samuel Goldwyn

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



[PHP-DB] Re: PHP/SSL and Hosting question

2003-02-27 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Chris Payne) writes:
 ... What is the best SSL to use on Windows ...
 [ snip ]
 ... any thoughts?

Kind of religious, but maybe not Windows at all, at least if you're
concerned about safety ;-)


-- 
--Fredrik
If God is dead, who will save the Queen?

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



[PHP-DB] Re: Processing Page

2003-02-27 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Aspire Something) writes:
 We are working on a project where the backend churns data for about
 1 Minute (time out limit is 2 min) we would like to put a page like
  PROCESSING  
 during the database is busy doing its fine job. And also a sucess
 page appears when the process is sucessfull.
 Please if you have any idea how it can be done please let me 

Since a client never can talk to a server with html pages this is
afaik not really possible. You'd have to use something like a java
applet, flash or something else that is able to talk to a server.

However, you could maybe work around it in some ways, I haven't tested
these, but I guess they should work to some extent:

1. Simple. Just make a page which reloads the target page after one
   minute. This, however, might be problematic if the work takes
   longer than one minute and would create needless waiting time if
   the work is processed quicker.

2. More or less the same as (1), but a little more sophisticated. Send
   a page that loads itself every five or ten seconds. For each
   reload, test if the work has been done, if not send the same page,
   otherwise, send a success page or whatever.

Others may have better solutions, and there could be problems with
these that I haven't thought of, but at least they're suggestions ;-)


-- 
--Fredrik
If God is dead, who will save the Queen?

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



[PHP-DB] Re: Get MySQL table schema for a dump

2003-02-26 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Jonathan Villa) writes:
 Is there was to get a database's table schema?

I don't think it's called schemas in mysql, but I'm not sure :-)

 So far, I have a simple function which will output 
 INSERT INTO table (x,x,x,) VALUES(x,x,x);
 [ ... ]
 but what I'm missing is 
 CREATE table blah, blah, blah

mysqldump is the tool you need.

e.g.
  $ mysqldump -u user [-p] Database  db_dump_file.sql

man mysqldump for more info.


-- 
--Fredrik
If God is dead, who will save the Queen?

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



[PHP-DB] Re: Question concerning hostnames

2003-02-25 Thread Fredrik de Vibe
[EMAIL PROTECTED] (2b4ever Php) writes:
 I want http://www.pageTwo.com to be redirected to
 http://www.pageOne.com/pageTwoindex.html, without losing the address
 http://www.pageTwo.com.

Maybe something like

  header(location: 
http://www.pageOne.com/pageTwoindex.html?ref=http://.$_SERVER[HTTP_HOST].$_SERVER[PHP_SELF;]);

on http://www.pageTwo.com

Then $_GET[ref] will contain the referers url provided
http://www.pageOne.com/pageTwoindex.html is a PHP file. If you just
want it for logging purposes, the url will still be saved in the
server log (at least if you use apache).


-- 
--Fredrik
In an organization, each person rises to the level of his own
incompetency
-- The Peter Principle

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



[PHP-DB] Re: PHP session problems

2003-02-25 Thread Fredrik de Vibe
[EMAIL PROTECTED] (David Rice) writes:
 I have been having trouble with PHP sessions, the session variables
 are not able to be called through the script.
 
 If have commented the area at the bottome where the session variable
 is NULL when var dump is called to check it (about 20 lines from the
 bottom... depending on if the text is wrapping or not)
[ snip ]
 ?
   session_start();
   session_register('valid_user');
   session_register('name');
   /* Start A Session */

- Is register_globals on or off?
- Which PHP version?

In PHP 4.2, I think, you have to use $_SESSION[foo] = bar instead
of session_register(foo) if register_globals is off. This is afaicr
fixed in 4.3.

[ snip ]
   form name=register method=post action=? echo $PHP_SELF; ?
   ?
[ snip ]
   session_register('valid_user');

You can't register a session variable after output. You have already
registered it, just set $valid_user = 'something'.

I might not remember everything completely, but the manual will at
least give you the correct answers if mine are wrong. ;-)


-- 
--Fredrik
In an organization, each person rises to the level of his own
incompetency
-- The Peter Principle

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



[PHP-DB] Re: PHP session problems

2003-02-25 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Fredrik De Vibe) writes:
 You can't register a session variable after output. You have already
 registered it, just set $valid_user = 'something'.

Sorry, I was a bit too quick here. You _can_ register session
variables after output...


-- 
--Fredrik
The chief cause of problems is solutions.

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



[PHP-DB] Re: question

2003-02-24 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Ali M) writes:
 Is this the place to post questions on php  db's?

php.db - yes ;-)


-- 
--Fredrik
Whether you can hear it or not
The Universe is laughing behind your back
-- National Lampoon, Deteriorata

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



[PHP-DB] Re: inserting binary data into a mysql blob field

2003-02-24 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Craig Kohtz) writes:
 [ inserting images into a mysql db ]

I haven't done it myself, but a search on php.net for blob mysql
file gave (among others)
http://www.php.net/manual/en/features.file-upload.php
(seach the page for 'blob').

On the other hand, it has been said that storing files in a mysql
database (severely(?)) affects performance. I don't know anything
about this myself, though, so I can't make any 'proper'
recommendations. However, it sounds plausible that searching through
the db might be quicker with files stored as files and the path to
them stored in the db.


-- 
--Fredrik
In an organization, each person rises to the level of his own
incompetency
-- The Peter Principle

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



[PHP-DB] Re: php/mysql query

2003-02-21 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Julie Keywell) writes:
 I am querying our database for 11,000 different zip codes and it seems
 to be overloading MySQL.  However, common sense says it shouldn't.
 
 My question is:
 When needing to query 11,000 things, is it best to make 1 SQL statement
 that has 11,000 ors, or run through individual querys 11,000 times?  Any
 help would be wonderful!  I am making PHP do the counting rather than
 MySQL.

I'm thinking join somehow, but I'm not sure I completely understand
the question. Post the query and table structure (you should change
the table names first, I guess, and only the necessary tables), and
maybe I for one can say more. :-)


-- 
--Fredrik
... and furthermore ... I don't like your trousers.

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




[PHP-DB] Re: Getting results from MySQL

2003-02-21 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Anders mellström) writes:
 I have a PHP-MySQl-problem. I would be very greatful if anyone
 would help me. I am - with the following code - trying to get
 results from a database. The problem isn't recieving the results,
 it's where i get the results. All the information is placed far down
 on the site, not in top. If you're having problems understanding
 what I'm trying to say, I don't blame you. I don't really understand
 either. The easiest thing would be for you to check the code, then
 got to the site link below to see for yourselves. Thanks //Anders
 
 link: http://medlem.spray.se/tippafotboll/full.php

As far as I can see this problem is html related. Your server, I
guess, spits out some script code after the /html tag. That _might_
cause some problems, try to strip the page of those and see if that
helps. I couldn't see anything else that would cause it.


-- 
--Fredrik
... and furthermore ... I don't like your trousers.

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




[PHP-DB] Re: mysql to cvs file to excel

2003-02-21 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Mark Snijders) writes:
 does anybody know if it's possible (without php) to export data from
 mysql to a cvs file, so i can import it in excel???

Not a cvs file, that's for sure, but I guess you mean csv. You can of
course script this with other languages than php, but you can use
mysqldump with the -T option to get a tab separated file, according to
the manual. Excel can to my knowledge import tab separated files.


-- 
--Fredrik
... and furthermore ... I don't like your trousers.

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




[PHP-DB] Re: displaying hyperlinks in MySQL query results

2003-02-20 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Rick Tucker) writes:
[ snip ]
 The first 3 columns return perfectly.  The Vendor URL data, on the other
 hand, is returned as text, rather than hyperlinks.  I've tried tweaking the
 code several different ways with no success.
 
 The following code is what I started with.  It returns everything I need.
 The HTML table is formatted correctly.  I thought I could use a 'hypertext'
 datatype in MySQL, but from what I see there isn't any such datatype.  And
 I'm so new to PHP I don't know how to isolate the Vendor URL field and
 convert the results to links.  Any help would be appreciated.
[ snip ]

A hyperlink (such as you speak of) is an HTML construct. You can save
one as text in a database, but the contents of the database are still
text. It can be interpreted as hyperlinks by a web browser, but then
it must contains a-tags (or similar).

This is as such not really neither a php nor a mysql issue. When you
print the url field, you have to print the html tag you need as well,
like you have done with the other tags you use (table, td and so
on). eg. printf(a href=\%s\%s/a, $url, $url);

http://www.blooberry.com/indexdot/html is a nice html resource.

Also, mysql_fetch_array($result) is easier to use, as it gives you an
associative array, you don't need the indexes and it doesn't give much
overhead (or at least, it's not supposed to). I wouldn't use a
foreach() construct in your case, either, it's easier (and should be
more efficient) to use something like
  printf(trtd%s/tdtd%s/td/tr\n, $data[0], $data[1]);
and so on.


-- 
--Fredrik
... and furthermore ... I don't like your trousers.

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




[PHP-DB] Re: Final Date Question :-)

2003-02-19 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Chris Payne) writes:
 pardon les francais :-)

Les Français - the (pl) french (people) ? ;-)

 I don't know how else to explain it so sorry if I confused you.

I don't know if anybody else might get this, but I have absolutely no
idea what you mean. If I'm to say anything, I think you have to post
some code.


-- 
--Fredrik
Faith, n:
That quality which enables us to believe what we know to be
untrue.

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




Re: [PHP-DB] Re: Final Date Question :-)

2003-02-19 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Chris Payne) writes:
 Basically what I mean is I have an orderform for rooms.  THey can select the
 date they arrive and the date they leave, but if they leave on a different
 month when the price is higher, the last day or however many will be a
 higher price, what I need is to not only calculate the flat price, but also
 take into account if their stay goes over a period of time when rooms are
 more than they are at other times of the year.
 So, they could book monday - friday, monday thru wednesday could be $50, but
 it needs to check and see if any of the dates - in this example - fall on a
 date that the prices are higher, so in this example thursday and friday
 would be $80 a night whereas monday thru wednesday would be $50.  It's hard
 to explain :-)

OK. I guess you have to check all the dates, then. You could do it by
starting with the first day, get the timestamp for that day
(mktime(0,0,0,m,d,y)), and then you can add 86400 (secs per day) to
this and check each day consecutively using e.g. the getdate()
function. (http://www.php.net/manual/en/function.getdate.php)

Something like (not tested):

// ...
$current_timestamp = mktime(0,0,0,$start_m,$start_d,$start_y);
// ...
for($i=0;$i$num_days_of_stay;$i++){
  $this_date = getdate($current_timestamp);
  // $this_date now contains all the info you need
  // Now, check for month, day of week etc. and update as needed
  // ...
  $current_timestamp += 86400;
}


-- 
--Fredrik
Faith, n:
That quality which enables us to believe what we know to be
untrue.

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




[PHP-DB] Re: string manipulation

2003-02-18 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Martin Dziura) writes:
 is there some sort of parsing call i can evoke to extract the url?
 Beginning with the http and ending with the first white space?

$str = foobarbazhttp://www.foo.bar/;;
preg_match(/(http:\/\/\S+)/, $str, $match);

$match[1] should contain the url part of $str. There are more
sophisticated regular expressions you can make for extracting url's,
but from your description, I think this should be enough.


-- 
--Fredrik
Calvin Coolidge looks as if he had been weaned on a pickle.
-- Alice Roosevelt Longworth

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




[PHP-DB] Re: Help with array

2003-02-16 Thread Fredrik de Vibe
[EMAIL PROTECTED] (John Thorne) writes:
 $data[$cpt]= $row[0].,.$row[1].,.$row[2].,.$row[3].,.$row[4];

What you need is a two dimensional array. The code above concatenates
the $row elements into a string and puts this string into a one
dimensional array.

the 2D array $foo[3][5] can be seen as:

   0 1 2 3 4
  +-+-+-+-+-+
0 | | | | | |
  +-+-+-+-+-+
1 | | | | | |
  +-+-+-+-+-+
2 | | | | | |
  +-+-+-+-+-+

and to put stuff into the two dimensions, you need something like
$foo[$i][$j] = bar;
and iterate over the values $i and $j.


-- 
--Fredrik
Why be a man when you can be a success?
-- Bertold Brecht

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




[PHP-DB] Re: Web Page Caching

2003-02-16 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Philip Zee) writes:
 I don't know if this is the right list to send this question to. It
 appears that the browser caches the result after a PHP page updates
 the database. I have to manually reload it in order to see the
 updates. Does anyone know how to overcome this?

If you put these before any output from your script, that might help.

header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);// Date in the past
header(Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT);
 // always modified
header(Cache-Control: no-store, no-cache, must-revalidate);  // HTTP/1.1
header(Cache-Control: post-check=0, pre-check=0, false);
header(Pragma: no-cache);  // HTTP/1.0

Read about cache control on e.g. http://vancouver-webpages.com/META/
and also check out http://www.php.net/manual/en/function.header.php


-- 
--Fredrik
Why be a man when you can be a success?
-- Bertold Brecht

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




[PHP-DB] Re: Help with array

2003-02-16 Thread Fredrik de Vibe
[EMAIL PROTECTED] (John Thorne) writes:
[ snip ]
 $data[$cpt]=
 $rownu.,.\.$row[0].\.,\.$row[1].\,.\.$row[2].\;

This is a string, not an array.

 Could you go a step farther in the $foo[$i][$j] please

$data[$cpt][0] = $rownu;
$data[$cpt][1] = $row[0];
$data[$cpt][2] = $row[1];
$data[$cpt][3] = $row[2];

should do what you want, I guess.

You can have many dimensions in an array. In your case, you have two.
$foo[][] means that each $foo[] contains another array, where the
elements of the second dimension can be accessed by $foo[$i][$j] ($i
and $j being integers and $foo a 2d array).

I don't know how many dimensions you can have in PHP, but I think you
can have more than two. A three dimensional one will be an array of
arrays of arrays, accessed with e.g. $foo[$i][$j][$k] ($i, $j and $k
being integers and $foo a 3d array).

Think of it as an index of books in a library. $foo[$i] contains a 2d
array of the different sections of the library, $foo[$i][j] contains
an array of the book shelves in each section and $foo[$i][$j][$k] is a
book.

Try to google a bit for multidimensional arrays and get a grip on how
they work. :-)


-- 
--Fredrik
Why be a man when you can be a success?
-- Bertold Brecht

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




[PHP-DB] Re: php date manupulation functions

2003-02-15 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Rajesh Fowkar) writes:
 Now while updating the form I want to retrieve the date and take out day,
 month and year from that date and display the correct selection in the
 combo. I could not find any function like say
 
 day($dbdate);
 month($dbdate);
 year($dbdate);
 
 Am I missing something ? Is there anyway to accomplish the above ? or I
 will have to store these three values separatly in the database rather than
 as a date.

Well, there is actually a quite good support for manipulating strings
in php. Have a look at the format of your date variable, and use
either the regexp functions or string functions like split and
explode.

Let's say your date is in a format like '-MM-DD hh:mm:ss'. Then
somehing like

list($yy, $mon, $dd, $hh, $min, $ss) = split( |:|-, $date);

would do the trick.


-- 
--Fredrik
A mathematician is a machine for converting coffee into theorems.

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




[PHP-DB] Re: printing repeat table headers

2003-02-15 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Sam Folk-Williams) writes:
 ...What I would like to do is have those headers repeat every 33
 rows...

 $tableHeaders = tr.../td;

$cnt = 0;

 while ($row = mysql_fetch_array($result)) {
// stuff

if($cnt%33 == 0){
  echo $tableHeaders;
}
$cnt++;

  echo $tableContent;
   } //close while loop


-- 
--Fredrik
A mathematician is a machine for converting coffee into theorems.

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




[PHP-DB] Re: while loop help

2003-02-15 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Peter Gumbrell) writes:
 if (isset($_POST['workshop_select']))
 {
 print $header_string;
 $user = $HTTP_POST_VARS['username'];
 
 * this is the section that needs some sort of loop 
if(isset($HTTP_POST_VARS['rank'])  is_array($HTTP_POST_VARS['rank'])){
  foreach($HTTP_POST_VARS['rank'] as $rank){
$r = substr($rank, -1);
ereg ('^[A-Za-z]*([0-9]+)-', $rank, $matches);
$workshop_ID = $matches[1];
if($r  0)
  mysql_query=(INSERT INTO choices(user_id, workshop_ID, rank) .
   VALUES ($user, $workshop_ID, $r));
  }
}
 *
 }

I guess the above code would do what you want. I can't see what the
'WHERE $rank  0' part in an INSERT query would be good for or how it
could be allowed, but there might be something I'm not aware of here
(not sure what you want to accomplish, but I guess an if test would be
right). Also, I presume you want '[0-9]+' in the regexp, but I never
use the ereg functions, so I'm not sure about the syntax. You
definitely want to look up the ereg function
(http://www.php.net/manual/en/function.ereg.php) as it only returns an
int, not a match.

I have NOT tested the above code.


-- 
--Fredrik
Why be a man when you can be a success?
-- Bertold Brecht

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




[PHP-DB] Re: TXT files with fixed width

2003-02-14 Thread Fredrik de Vibe
[EMAIL PROTECTED] (Pedro Oliveira) writes:
 I need to import a fixed width txt to a my sql database, I
 know how to do that with a coma separated value.
 any1 knows how i can do this easilly or know some software to do this?
 any help would be appreciated.

*nix or windows? If the file is tab separated, I guess you can use
excel or something and export it to comma separated. On *nix, you have
an abundance of utilities, e.g. tr(1).

When you say fixed width, I guess it's not tab separated, however,
maybe:

# 345678901234567890123456789012345678901234567890
word1word2 word3 someword4 another5

or something like that. Then you can e.g. use perl (or for that sake
PHP) and the substr function to parse the data and spit them out
either in sql, directly into the database or comma separated (or in
whichever format you desire).


-- 
--Fredrik
Subtlety is the art of saying what you think and getting out of the way
before it is understood.

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




[PHP-DB] c binary for (more securely) connecting to oracle

2003-02-09 Thread Fredrik de Vibe
Hi

It's the old question all over again: How can I make my user / pass
impossible to read for those who shouldn't?

I've been thinking a lot the past few years about how to do this, and
I've thought that one solution, a little better than keeping the
information in a file in plain text, would be to put them in a small c
program, compile it and restrict access to execute (by the server).

This would still mean that others can run the program through the web
server, so if there could be a way of checking for which script is the
callee of the program, that would be best, but i doubt there is... :þ
Nevertheless, if anybody has any idea to whether this is possible or
not (and how), please let me know.

I've started looking into this and made a small program that makes a
connection to oracle. The rest isn't quite trivial. As far as I've
understood, PHP uses it's own structs for representing the oracle
connection, and I don't really know how one would go about trying to
return this to PHP. Other than that there might be someone out there
who has done this before or someone who can tell me that this isn't
possible for some reason I haven't thought about. I'm not too
experienced in c programming, so any hints would be greatly
appreciated. :-)

Hints? Comments? Solutions?

Thanks in advance.


-- 
--Fredrik
Life to you is a bold and dashing responsibility
-- a Mary Chung's fortune cookie

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