[PHP] Comparison Problems with 5.2.5

2007-12-30 Thread Magnus Anderson

Hi,

I have runned into a slight annoying problem with my code, that I have never
had before.
Either I have something wrong in my code or PHP 5.2.5 that I user is acting
weird in windows. I have recently installed PHP on my windows machine for
local developement instead of a remote server.

What I try to do is to make an if statement betwean two string numbers.

$_USER['level'] = The level the user has

The $_USER['level'] string is taken from the Database and is 5.

This will not work (I expect this to work since _USER['level'] is 5)
if($_USER['level'] = 5)

This will work (And I expect it to work to)
if($_USER['level'] = 6)

This will work (Not supposed to work since _USER['level'] is 5)
if($_USER['level']  5)

-- 
View this message in context: 
http://www.nabble.com/Comparison-Problems-with-5.2.5-tp14547671p14547671.html
Sent from the PHP - General mailing list archive at Nabble.com.

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



[PHP] Check valid chars in string

2002-12-02 Thread magnus nilsson
function valid_chars($file_name)
{

  for($i = 0; $i  strlen($file_name); $i++)
  {
  if (!in_array($file_name[$i], 
array('q','w','e','r','t','y','u','i','o','p','l','k','j','h',
'g','f','d','s','a','z','x','c','v','b','n','m','Q','W',
'E','R','T','Y','U','I','O','P','L','K','J','H','G','F',
'D','S','A','Z','X','C','V','B','N','M','0','1','2','3',
'4','5','6','7','8','9', '.', '_')))
 {
 return false;
}
else
{
 return true;
  }
}

Found this snippet of code on php.net 
(http://www.php.net/manual/sk/ref.strings.php), but it just reurns a 
parse error.


OS: OS X 10.2
PHP: PHP 4.2.3
MYSQL: 3.23.51

// magnus n.
 
  

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



[PHP] strange parse error at EOF

2002-12-01 Thread Bård Magnus Fauske
Hello.

Get a strange parse error at End of File

Any suggestions what I do wrong? I use UNIX-formatted text-file written in 
windows-client and uploaded to server. Using PHPEDIT to check I get the 
same error as when I visit the page, and I can't find any error looking 
through the file (/,/; etc.).

I use
?php

?

as start/end tags in php

Address to webpage:
http://studorg.nlh.no/storband/wopen.php

Address where you can download the file
http://studorg.nlh.no/storband/docs/wopen_was_php

Bård Magnus 


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



[PHP] Upload wont work, OS X

2002-11-29 Thread magnus nilsson


I have trouble using upload scripts - none of them work on my current 
config. I'vq got php 4.2.3 and global registerd = off. The problem is 
that the script doesnt send the variable $_FILES['my_file'] as it 
should. I can only upload if i hard code the filename into the script.

OS: OS X 10.2
PHP: PHP 4.2.3
MYSQL: 3.23.51


// the script i've tried, it works with older versions av php.

?php
 // Programmerer: Kim aka astrox
 // Mail: [EMAIL PROTECTED]
 // Dato: 19.04.2002
 // Hjemmeisde: www.htmlhjelp.no
?

h3Bilde upload/h3

Dette scriptet uploader bilder og bare bilder!br
Dvs.. *.jpg, *.gif og *.pngbrbr

?php
#Config

$MAX_FILE_SIZE = $_POST['MAX_FILE_SIZE'];
$bilde_fil = $_FILES['bilde_fil']; // HTTP_POST_FILES
$nyttnavn = $_POST['nyttnavn'];
$ending = $_POST['ending'];
$Upload = $_POST['Upload'];

echo is_array($HTTP_POST_FILES['bilde_fil']);

print_r($bilde_fil);

print $bilde_fil;

$path=upload; //Mappa som bildene skal havne i (husk den siste '/')

#Ikke rediger under her hvis du ikke vet hva du driver med :)
if ($bilde_fil  $nyttnavn){
   $ok = 1;

   if (is_file($path.$nyttnavn.$ending)){
  print bSorry/b, fila eksisterer allerede, finn p et nytt 
navn.br;
  $ok = 0;
   }
   if (preg_match(/^[\/\\\.]/, $nyttnavn)){
  print bSorry/b, filnavnet kan ikke begynne ned: '.', '/' 
eller '\'br;
  $ok = 0;
   }
   if (!($ending == .jpg || $ending == .gif || $ending == .png)){
  print bSorry/b, ingen triksing med filendingen ($ending) 
takk!br;
  $ok = 0;
   }
   print br;
}

if ($ok){
   $res = copy($bilde_fil, $path./.$nyttnavn.$ending);
   print ($res)?bFerdig/b, uploadet 
.$nyttnavn.$ending.!br:bSorry/b, Kunne ikke uploade.br;
   print br;
}
?


form name=formen action=upload.php method=post 
enctype=multipart/form-data
input type=hidden name=MAX_FILE_SIZE value=100

Bilde: input type=file name=bilde_filbr
Hva skal fila hete p servern: input type=text name=nyttnavn
select name=ending
option.jpg/option
option.png/option
option.gif/option
/select
brbrinput type=submit value=Upload
/form


Re: [PHP] Upload wont work, OS X

2002-11-29 Thread magnus nilsson
It works, partially. I can upload the file, but it's named array.


On fredag, nov 29, 2002, at 16:28 Europe/Stockholm, Beth Gore wrote:


Hi Magnus,

Your problem was you weren't using the correct part of the $_FILES 
array when using copy();


Cut and Past This:


if ($ok){
  $res = copy($bilde_fil[tmp_name], $path./.$nyttnavn.$ending);
  print ($res)?bFerdig/b, uploadet 
.$nyttnavn.$ending.!br:bSorry/b, Kunne ikke uploade.br;
  print br;
}
?


The Important bit is the $bilde_fil[tmp_name] bit. This means it's 
copying the file from the temporary location on the server to your 
chosen location.

Also, as a side note, replace this too:


$MAX_FILE_SIZE = 100;
$bilde_fil = $_FILES['bilde_fil']; // HTTP_POST_FILES
$nyttnavn = $_POST['nyttnavn'];
$ending = $_POST['ending'];

if($bilde_fil[size]  $MAX_FILE_SIZE)
{
   die(bSorry/b, Kunne ikke uploade.br);
}

$path=upload; //Mappa som bildene skal havne i (husk den siste '/')


Don't set $MAX_FILE_SIZE using $_POST variables for security reasons - 
someone could very easily alter it in the HTML file!!!

Beth Gore


magnus nilsson wrote:



I have trouble using upload scripts - none of them work on my current 
config. I'vq got php 4.2.3 and global registerd = off. The problem is 
that the script doesnt send the variable $_FILES['my_file'] as it 
should. I can only upload if i hard code the filename into the  script.




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





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




[PHP] DomDocument-dump_file don't work!

2002-10-25 Thread Magnus Stålberg
I can't get the DomDocument-dump_file($file, false, true); to work.!
help needed!
Everyting else works just fine.

Running
IIS5
PHP 4.2.3



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




[PHP] unless something...

2002-09-12 Thread Magnus Solvang

I'm used to the unless-statement in perl... How do I do this:

  if string A or B are NOT in string C, then do something and quit.

In perl, I would do this:

unless ($c =~ /$a|$b/) {
  blabla
  exit 0
}

- M

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




[PHP] Checking Insert to Postgre, whats wrong?

2002-07-28 Thread Bård Magnus Fauske

Hello.

I use this code-snip similar to this to check if the inserted tuppel in my 
database was successfull:
--- snip ---
$OID = pg_last_oid($resultat);
if($OID0) {
echo $errormessage;
exit;
}
$query = SELECT * FROM medlemmer WHERE oid = '$OID';;
$resultat = pg_query($dbconnection, $query);

if (!$resultat) {
echo $errormessage;
exit;
} else {
$i = 0;
$medlem_id[$i] = pg_fetch_result($resultat, $i, medlem_id);
$fornavn[$i] = pg_fetch_result($resultat, $i, fornavn);
}
pg_free_result($resultat);
if (!$medlem_id[$i]) {
echo $errormessage;
exit;
} else {
$i = 0;
echo $medlem_id[$i].$fornavn[$i];
}
--- snip ---

But when I print the result from pg_fetch_result() to the browser (last 
lines above), I only get the first letter in the string $fornavn[$i] and 
similar strings not listed above, not the whole string. What is the reason 
for this? Has it something to do with the pg_last_oid()? I can't see how 
since this only identify the inserted row (or am I wrong?) which I select 
afterwards.

Thanks for answer.

Bård Magnus


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




[PHP] mail() returned a strange error, what is this?

2002-05-30 Thread Magnus Hammar

I used the mail() function in php and it returned errors like these:
--
Warning: Mail delivery program returned with exit code: 17152 in
/www/htdocs/mail_webmaser.php on line 216

Warning: Mail delivery program returned: Undefined error: 0 in
/www/htdocs/mail_webmaser.php on line 216
--

Can anyone explaun why I get these errors, mail() with sendmail is
working fine with other php-sites on the server...

Thanks.
/Magnus Hammar



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




Re: [PHP] Re: Serious problem with Cookies..

2001-11-15 Thread Magnus

Den 01-11-15 13.20, skrev PHPGalaxy.com [EMAIL PROTECTED]:

 yeah I saw that bit on there, but I was led to believe tha by leaving it out,
 it would make the cookie permanent...I see thats not true =)  so what would I
 do to make this permanent? or would I just set it for the highest time-limit
 possible? =)

If you set it like this:
?
$hour = 3600;   // One hour
$day = $hour * 24;  // One day
$year = $day * 365; // One year
$year = $year * 2;  // 2 years
setcookie (TestCookie, $value,time()+$year);  // Expire in 1 year
?

There is not a good way to set a permanent cookie, the user can always
delete them if he wants to.

Thanks.
/Magnus Hammar


-- 
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] Need a little help with IMAP (OT?)

2001-11-14 Thread Magnus

Hello all!

I have finally got php and apache to work with IMAP, pdf and gd, not
problems compiling them.

But...
When I try to connect to my local account called homer with IMAP in a
php-page I get an error:
Warning: Couldn't open stream {localhost:143}INBOX

When I get more info about the error from IMAP I get Unable to connect,
connectiosn refused.

When I connect to the server via ftp I get the same error Connection
refused.

Is there anyone who knwos what's wrong and how to get thins running? :-)

I'm running RedHat 7.1 with the latest stable version of PHP and IMAP and
Apache.

Thanks.
/Magnus Hammar
--


-- 
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] SSL and PHP = problems?

2001-09-11 Thread Magnus

I have a webpage that uses php4 and a SSL connection for some sensitive
information like credit card number and such, it's a registration process.

When MacOS users access the page it all goes well and no problems at all.
But... when PC/Windows users access the page they get some problems and it
shows every now and then so it's hard to know what causes it.

I have a screenshot of the error that accure that causes them to do the
registrationprocess again and it's a bit annoying:
http://www.programmering.nu/felmeddelande.gif

Do you think this is because of bad PHP-programming or is it because of the
SSL, or do you have any other sugestions?

I find it hard to beleve that it is because of the programming because
before the SSL-connection when I only have a regular HTTP-connection there
were never any problems, and it works fine with MacOS users.

Please help! ;)

Thanks.
/Magnus Hammar
--


-- 
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] Cookie Not Setting..

2001-07-11 Thread Magnus Hammar

Some things to keep in mind:

1. The cookie can't be read untill the next time you access a page.

2. The cookie can only be red in the same level as it is set (I guess), that
means that if you set a cookie in /my/pages/index.php you can't read the
cookie from a page in /my/index.php.

3. To really see if the cookie is set you can use Netscape and let it warn
you before accepting a cookie, in that way you will see the cookiename and
it's value and then you can be sure the cookie is set.

4. You can do the same thing with IE.

/Magnus Hammar - The cookiemonster? =)
--
 Still no luck.  Do I have to read a cookie before any HTML is sent as well?
 I know to set it before it is sent but reading?
 
 Jeff
 - Original Message -
 From: Magnus Hammar [EMAIL PROTECTED]
 To: Jeff Lewis [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, July 11, 2001 9:30 AM
 Subject: Re: [PHP] Cookie Not Setting..
 
 
 Try this:
 
 $cookie_name= wwblCookie;
 $value  = PLEASE;
 $exp= time() + (86400 * 365);
 $server = www.domain.com; // Or IP-address will also do fine
 // the domain must cuntain three .
 // as in .somedomain.com
 $secure = 0;
 setcookie($cookie_name, $value, $exp, /, $server,$secure);


-- 
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] SMTP-access with PHP...

2001-06-20 Thread Magnus Hammar

Hello!

Why do I get this error (Relaying denied ) from my SMTP-server and how do I
make it work?

220 mail.server.com ESMTP Sendmail 8.9.3/8.9.3; Wed, 20 Jun 2001 15:09:06
+0200 (CEST) 
250 mail.server.com Hello localhost [127.0.0.1], pleased to meet you
250 [EMAIL PROTECTED] Sender ok
550 [EMAIL PROTECTED] Relaying denied
503 Need RCPT (recipient)

Is there something else I can do to make it work?
I use this code:
-
$smtp_server = localhost;
$port_number= 25;
$smtp_connection= fsockopen($smtp_server, $port_number);
if(!$smtp_connection){
$smtp_connection= fopen($smtp_server.:$port_number,w);
}
if(!$smtp_connection){
$return_value = SMTP-server not responding!;
return 0;
}else{
fputs($smtp_connection, );
$return_value = $return_value.fgets($smtp_connection,128).br;
fputs($smtp_connection, HELO $smtp_server\n);
$return_value = $return_value.fgets($smtp_connection,128).br;
fputs($smtp_connection, );
fputs($smtp_connection, MAIL FROM: $from\n);
$return_value = $return_value.fgets($smtp_connection,128).br;
fputs($smtp_connection, );
fputs($smtp_connection, RCPT TO: $till\n);
$return_value = $return_value.fgets($smtp_connection,128).br;
fputs($smtp_connection, );
fputs($smtp_connection, DATA\n);
$return_value = $return_value.fgets($smtp_connection,128).br;
fputs($smtp_connection, Subject: $subjekt\n);
fputs($smtp_connection, Reply-To: $from\n);
fputs($smtp_connection, MIME-Version: 1.0\n);
fputs($smtp_connection, Content-Type: text/plain; charset=iso-8859-1\n);
fputs($smtp_connection, Content-Transfer-Encoding: 8bit\n);
fputs($smtp_connection, X-mailer: Magnus Mail);
fputs($smtp_connection, \n\n);
fputs($smtp_connection, $bodyn\n\r);
fputs($smtp_connection, );
$return_value = $return_value.fgets($smtp_connection,128).br;
fputs($smtp_connection, );
fputs($smtp_connection, QUIT\n\r);
$return_value = $return_value.fgets($smtp_connection,128).br;
fclose($smtp_connection);
return $return_value;


/Magnus Hammar
--




Re: [PHP] SMTP-access with PHP...

2001-06-20 Thread Magnus

Den 01-06-20 18.28, skrev Andreas D. Landmark
[EMAIL PROTECTED]:

 Contact your mailserver admin and get him/her to open for relay from the IP
 of your
 webserver.

Thanks, I'll try that and see what will happen.

Sincerely,
/Magnus Hammar
--


-- 
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] carriage return (writing files)

2001-05-09 Thread Magnus Lawrie

hello,
I'm writing to files with php. How do I include a carriage return, i.e.
write strings to different lines in a text file?
Thanks,


-- 
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] slashes \ appearing

2001-05-04 Thread magnus lawrie

I am using a form to test posting a variable. If my variable looks like this
in script post_var.php3 :

stringinaaform

then  it comes out like this in recieve.php3 :

\stringinaaform\

why? thanks in advance.



-- 
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] appended with \

2001-05-04 Thread magnus lawrie

I am using a form to test posting a variable. If my variable looks like this
in script post_var.php3 :

stringinaaform

then  it comes out like this in recieve.php3 :

\stringinaaform\

why? thanks in advance.





-- 
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]