Re: [PHP] Searching for array keys

2001-05-04 Thread Martin Skjldebrand

Mark Charette wrote:

 
  What's the best way of finding out if a specific array key is in an
 array?
  I have an associative array which *may* look like
  (car =saab, house = mansion, countyW= A) but can equally well look
 like
 
  (boat = daycruiser, house = flat, county = B).
 
  I want to find out if the key car is in the array and do something if
 it
  try something like

 if (in_array(keyb,array_keys(array(key=a,keyb=b) {
 ...
 }
 
 Maybe I'm being dense here, but won't a simple isset() work (using the
 KISS principle)?
 
 $ary=array(aa=yy,bb=zz);
 
 $key=aa;
 if (isset($ary[$key]))
 print $key set\n;
 else
 print $key not set\n;
 
 $key=bb;
 if (isset($ary[$key]))
 print $key set\n;
 else
 print $key not set\n;
 
 $key=cc;
 if (isset($ary[$key]))
 print $key set\n;
 else
 print $key not set\n
 
 returns
 
 aa set
 bb set
 cc not set
 
Thanks, 

So simple - giving it more thought than before rushing off to work I would 
possibly have found it myself.

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Even more dynamic page

2001-05-04 Thread Martin Skjldebrand

Is there some way of making PHP even more dynamic?
What I would like is that selecting a value from a SELECT box would 
change some info on the page - without having to click a refresh button 
or something like that. 

Or do I have to resort to javascript for such things?

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Searching for array keys

2001-05-03 Thread Martin Skjldebrand

What's the best way of finding out if a specific array key is in an array?
I have an associative array which *may* look like 
(car =saab, house = mansion, countyW= A) but can equally well look like 
(boat = daycruiser, house = flat, county = B).

I want to find out if the key car is in the array and do something if it 
is.

I found:

$os = array (Mac, NT, Irix, Linux);
if (in_array (Irix, $os)){
do stuff;
}

But that only works on the values. But it is exactly what I want to do on 
keys instead.

Suggestions?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Going crazy again ...

2001-05-01 Thread Martin Skjldebrand

Going grey haired again. In this code only the first case is working 
(adding stuff to tables). The second and third are producing - Warning: 
Supplied argument is not a valid MySQL-Link resource in 
/chroot/htdocs/diarium/settings.php on line 31 (which is $query_res /ms)
error:

I've even copied and pasted the also clause which works from sendaction to 
recaction but I get the same result. Anyone sees what going on? I don't. 
And my deadline is tomorrow (or thursday).

M.


switch ($sendaction) {
case "Lgg till":

$query="INSERT INTO employees (login, name)";
$query .= "VALUES('$txtSend', '')";
$query_res =mysql_query($query, $mysql_link) or die('error: ' 
. 
mysql_error());
if ($also=="Rec"){
$query="INSERT INTO contacts (id, name)";
$query .= "VALUES('$txtSend', '')";
$query_res =mysql_query($query, $mysql_link) or 
die('error: ' . 
mysql_error()); 
}
break;
}

switch ($recaction) {
case "Lgg till":
$query="INSERT INTO contacts (id, name)";
$query .= "VALUES('$txtRec', '')";
$query_res =mysql_query($query, $mysql_link) or die('error: ' 
. 
mysql_error());
break;
}   

switch ($archaction) {
case "Lgg till":
$query="INSERT INTO archive (s_name, name) VALUES('$txtArch', '')";
$query_res =mysql_query($query, $mysql_link) or die('error: ' 
. 
mysql_error());


break;
}   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Going crazy again ...

2001-05-01 Thread Martin Skjldebrand

Jimmy Lantz wrote:

 
 Hej, jag hade nog inte anvnt  i case men det r bara en vana, kanske
 du kan anvnda en dold variabel via html-formulret istllet och anvnda
 den i case satsen? Men det svarar ju inte p din frga men lycka till.
 / iImmy

Fixat!
Problemet lg ngon annanstans, vilket jag upptckte nr jag pltsligt fick 
ett annat fel i scriptet. ndrade dessutom "Lgg till" till "Skapa" vilket 
ju inte innehller vra tecken. Verkade ju funka nd men fr 
skerhetesskull s.

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Going crazy again ...

2001-05-01 Thread Martin Skjldebrand

Altunergil, Oktay wrote:

 I was actually interested in the answer to this. I believe one can write
 in English if one can read English. (PS: It's not my first language
 either)


AS it was my question I'll answer.
He said that he was sceptical about using our accented character in code 
and that that I could use a input hidden ... instead of whatever to track 
the variable.

Well, I fixed it eventually - the problem was somewhere else, which I 
noticed when I got a completely different error message later. 'Twas due to 
stupidity of the coder rather than the quoted code itself.

M.


 
 Hej, jag hade nog inte anvnt  i case men det r bara en vana, kanske
 du kan anvnda en dold
 variabel via html-formulret istllet och anvnda den i case satsen?
 Men det svarar ju inte p din frga men lycka till.
 / iImmy


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Where is php.ini located by default?

2001-04-28 Thread Martin Skjldebrand

idban secandri wrote:

 On Saturday 28 April 2001 00:37, you wrote:
 I've built php from a tarball. Now I need to specify a special include
 path in the php.ini file. But I can't find it. There is a php.in-dist in
 the build catalog but I can't find a production php.ini anywhere.
 The docs says that it should be in the install catalogue (which is
 where?, /usr/local/lib/php doesn't have one) or the cwd. I've tried
 editing the sample file and putting it in either place but my app still
 gives me the following error:

 Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php')
 in FILENAME

 Martin S.
 
 
 read INSTALL doc, they will told you
 
Found the litte line.
Thanks - too all who replied!

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Where is php.ini located by default?

2001-04-27 Thread Martin Skjldebrand

I've built php from a tarball. Now I need to specify a special include path 
in the php.ini file. But I can't find it. There is a php.in-dist in the 
build catalog but I can't find a production php.ini anywhere.
The docs says that it should be in the install catalogue (which is where?, 
/usr/local/lib/php doesn't have one) or the cwd. I've tried editing the 
sample file and putting it in either place but my app still gives me the 
following error:

Failed opening required 'class.DBI' (include_path='.:/usr/local/lib/php') 
in FILENAME

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: SV: [PHP] PHP Book?

2001-04-27 Thread Martin Skjldebrand

[EMAIL PROTECTED] wrote:

 On Fri, Apr 27, 2001 at 08:06:54PM +0200, Christian Reiniger wrote:
 On Friday 27 April 2001 15:15, Johan Holst Nielsen wrote:
   Hey everyone...
  
   I've been programming in perl for about 3 years now, i have installed
   php and have been working on it for about three weeks. I started by
 
  Try Core PHP Programmning, it's have a lot of good stuff!
 
 That book is definitely the wrong choice for someone with 3 years perl
 experience (perhaps unless there's a second edition).  The copy I
 unfortunately bought is built somehow like that:
 
 What books are you reading?
 
 5 pages useful intro
 45 pages explaining basic language contructs [1]
 4 pages explaining classes
 11 pages giving a (small) overview of using print(), getting data from
 forms, file upoads, env-vars, cookies, include/require and file IO
 340 pages function references (copied from the manual) [2]
 
 That is wrong. Leon havent copied 340 pages from the manual. I should know
 this myself because I have finished the translation into German.

Well, for the first edition of this book I found it extremely boring. Don't 
know why really. The whole thing felt pretty old - but it isn't. Hopefully 
the second ed. is much better. (I know many people like PHP Core).

Anyway, PHP Developers Cookbook (Sterling Hughes) from SAMS is very nice. 
Gives lot's of examples of everyday stuff you'd like to do.

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Autoupdate of page

2001-04-24 Thread Martin Skjldebrand

IS there a standard way of auto-updateing the contents of a page after a 
databas insert or edit? Do a SELECT updates the contents I can update 
tables I've noticed. Contents in select boxes (as in

 while ($row = mysql_fetch_row($secquery_res)) {
print option$row[0]/option;
  }
)

is not automatically updated to match edits or inserts done on the same 
page. You have to initialize the select box again. Or is there another way?

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] checking if e-mail address and syntax are valid

2001-04-24 Thread Martin Skjldebrand

Carlos Fernando Scheidecker Antunes wrote:

 Hello all!
 
 I would like to know if anyone has or know any PHP code to verify if a
 form entered e-mail address is valid?
 
 I would like that things like 4$%^%$@@.com.br could not be sent. I only
 has to verify the syntax of it, the existance I believe should be harder
 to verify but if it is possible I would be glad if anyone could point me
 the way.

This is taken from PHP Developers Cookbook. Don't ask me exactly what it 
does, because I don't know. I think I can grasp the basics of it though.
It isn't fool proof tho.


if (!eregi (^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$, 
$users)) die (Invalid email);

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] BASIC function question

2001-04-23 Thread Martin Skjldebrand

I have a function on an include page that says

function update_stuff($database)
{
include(includes/connect.inc.php);
include(config/db.conf.php);
$query=SELECT * FROM $database;
$query_res=mysql_query($query, $mysql_link);
$isequip=mysql_num_rows($query_res);
}

If I call it from a script as
update_stuff(equipment);

I don't get any result (I want to page to automagically update it's 
contents) while if I include the query lines after each edit case
it does update the page contents.

I'm missing something basic, but what?

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Incrementing dates

2001-04-22 Thread Martin Skjldebrand

PHPBeginner.com wrote:

 
 INSERT INTO table SELECT date+INTERVAL 10 DAYS AS date FROM table WHERE
 bla=bla;
 
 it is just a way to do it. you will definitely have to play with it.
 
 However you can easily make two queries to read the previous date
 combining it with INTERVAL and then do an insert.

I've looked at INTERVAL but it seems it only deals with one specific date 
at a time?

date=10 : SELECT date+INTERVAL 10 
would then mean date=20

Or have I got everything wrong?

What I looking at
from the value of date=10 ADD other dates for X days on, like this
(in a table, each record (row) has more data than the one given)
date=2001-04-10
date=2001-04-11
date=2001-04-12

This, if I'm mistaken can't be done with interval, at least not without 
looping in PHP? And using two queries would not perhaps save as much code 
as the way I solved it? Could be mistaken of course.

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Incrementing dates

2001-04-22 Thread Martin Skjldebrand

PHPBeginner.com wrote:

 I am not sure on how your possibilities are,
 but doing this in PHP means literally "adding useless lines and loops"
 
 If possible, do it with SQL queries. Read the documentations on date
 datatypes, this is so much easier... almost magic.
 

AND 

 You can (mySQL, right?) do the following:

UPDATE table SET date=(date+INTERVAL 10 DAYS);

so if date there was 04-28, it will be added 10 more days and so will 
become
05-08

Use SQL for this things, it treats dates as 'dates' while PHP treats them 
as
integers and strings.

Sounds even easier. But what if I'm not doing an UPDATE but an INSERT? Can 
it read the previous date? I am inserting a batch of bookings at one time.

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Incrementing dates

2001-04-22 Thread Martin Skjldebrand

James, Yz wrote:

If anyone has any comments on this, I'd like to
 hear
 them (there's probably a simpler way around what I have done).  Here's the
 URL:
 
 http://www.yorkshire-zone.co.uk/date_increment.php
 
 And here's the code that powers it:
 
 HTML
 BODY
 
 ?
 
 $date = date("2001-04-28");
 list($year, $month, $day) = explode("-", $date);
 
 $actual_date = mktime(0,0,0,$month,$day,$year);
 
 $days_to_add = 7;
 
 $x = 1;
 
 while($x = $days_to_add) {
 
  $make_date = getdate($actual_date);
 
  echo "Day $x: $make_date[mday] $make_date[month],
 $make_date[year]BRBR";
 
  $actual_date = $actual_date + (3600 * 24);
 
  $x++;
 
 }
 
 ?
 
 /body
 /html

Thanks James!

You started me off in the right direction. And ... with a few beers less in 
the brain (and a look at php.net and PHP Developers Cookbook) I finally 
found that mktime actually increments dates correctly.
So, given that $month, $day and $year are valid and that we want to add 10 
days to the output we can do:

echo date ("Y-m-d", mktime (0,0,0,$month, $day, $year)) . "br";
for($i=1; $i=9; $i++) {
  $day++;
  echo date ("Y-m-d", mktime (0,0,0,$month, $day, $year)) . "br";
}

Cheers,

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Incrementing dates

2001-04-21 Thread Martin Skjldebrand

How do I increment dates past the turn of the month (or year)?
Say I've got a booking of equipment A for the 28 April to 5 May and want to 
add each instance to a calendar (mysql table).
Can I increment the variable (format 2001-04-28) holding the date 
($txtDate++) somehow so that it doesn't add the 31, 32 and 33 of April?

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] HELP!! print problem

2001-04-17 Thread Martin Skjldebrand

I'm blind!!
Whats wrong here? $besk has a value at one place but not in another?

Jeez 

M.

 $besk=$row1[0];
 print "beskr $besk"; -- prints value of $besk

 print "tdinput type='text' name='txteItem' size='20' maxlength='20' 
value='".$eItem."'/td"; -- works
print "   tdinput type='text' name='txteDesc' size='50' maxlength='50 
value='".$besk."'/td"; -- DOES NOT PRINT A THING!!
   print "  tdinput type='text' name='txtePrice' size='10' 
maxlength='10' value='".$row['s_price']."'/td"; -- works
  print "   tdinput type='text' name='txteQuant' size='10' 
maxlength='10' value='".$row['s_stock_quantity']."'/td"; --works

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] HELP!! print problem

2001-04-17 Thread Martin Skjldebrand

[EMAIL PROTECTED] wrote:

 You're missing a single quote after the value of MAXLENGTH on the line
 that's not working...  Maybe that's the problem.
 

Yes!!
Thanks! I thought I was going crazy.

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] sessions problem (and spec. Mozilla vs Opera)

2001-04-15 Thread Martin Skjldebrand

On my login page (index.php) I have at the top

?
  session_start();
  session_destroy();

The intended function of which is to stop people from hitting the Back 
button to reenter the site after having logged out (which bring people to 
the page index.php).

Now, hitting BACK on Mozilla results in failed authentication and the app 
closes. Hitting BACK on Opera (5.0b7 Linux) you get into the app again but 
selecting anything from the menus results in failed authentication.

Which one is behaving correctly? Is it a bug in Opera (hopefully).

If, when logged in you go somewhere else, e.g. www.sunet.se, THEN hit back 
you get back in. Is there a way of stopping this?

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Netscape 4.77 and PHP

2001-04-15 Thread Martin Skjldebrand

Adam wrote:

 try sending us the sample code. I use netscape 4 for testing and it seems
 to work just fine.

My whole project is based on inserting pieces of html. Works like a dream 
in Netscape 4.75 Linux.

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Mailbox and PHP

2001-04-15 Thread Martin Skjldebrand

Richard wrote:

 Greetings.
 
 I have no problem writing an email client in PHP, which sends emails
 and
 such things. One thing only, can I check someones POP3, such as mine,
 through PHP? If so, what should be needed to complete it..? The server I
 am using is running Linux FreeBSd (I think..) with the options for the
 user to change quite alot..


You can find a class lib in the e-mail section at the address below. Don't 
know how good it is, but I've done a (very) quick test and it does work.

http://phpclasses.upperdesign.com/browse.html/package/2

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Want a Good Book for Ref on PHP

2001-04-15 Thread Martin Skjldebrand

Kath wrote:

 Professional PHP Programming:
 
http://www.amazon.com/exec/obidos/ASIN/1861002963/qid=987388364/sr=1-12/ref=
 sc_b_13/002-2263539-0333643

I've got Beginning PHP 4 (recommended) on the back cover of which it says 
that the next book could be "Professional PHP Programming.".
However from what I saw in the book shop they cover lots of the same 
ground. I (and my employer) wouldn't like to pay for the same stuff again.
Is there a significant difference between the two?

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] mystery line

2001-04-05 Thread Martin Skjldebrand

It's not first of April today is it?

In:

? if ($id != "") {

  print "center";
  print "pTID detail view - Document #b?php echo $id; ?/b/p";
 

$sql="select * from tid_tbl where id=" . $id;
$result1=mysql_query($sql, $mysql_link);
$row = mysql_fetch_array($result1);
echo 'table border="1"';
echo 'trtd BGCOLOR="' . $headerbg . '"Subject/tdtd' . 
$row["subject"] . '/td/tr';
echo 'trtd BGCOLOR="' . $headerbg . '" valign="top"Issue/Info/tdtd' 
.  ereg_replace (13, "", nl2br($row["body"])) .  '/td/tr';
echo 'trtd BGCOLOR="' . $headerbg . '"Author/tdtd' . $row["author"] 
. '/td/tr';
echo 'trtd BGCOLOR="' . $headerbg . '"' . $contact . '/tdtd' . 
$row["company"] . '/td/tr';
echo '/table/center';
} 
?

The third line (starting print "p TID detail") is my mystery line.
If I comment it out ("// print "p TID detail...") the parser chokes on on 
the last line (or I suppose somewhere between).
While I totally delete it everything is OK. What is the parser seeing that 
I'm not?

M.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] mystery line

2001-04-05 Thread Martin Skjldebrand

Tyler Longren wrote:

 In line 3, you don't need your ? ? tags again.
 This is how you have it:
 print "pTID detail view - Document #b?php echo $id; ?/b/p";
 
 this is how it should be:
 print "pTID detail view - Document #b$id/b/p";

Ofcourse, I've seen that all the time - and yet ...
oh well ... a bug in the carbon based part of the system I suppose.

Thanks,

Martin S.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]