Page 1 of 1
Little progblem with variables
Posted: Wed Aug 28, 2002 8:57 am
by Zeceer
$fil = brukere/$_POST['brukernavn']$_POST['passord']
$open = fopen( $fil, 'a' );
fputs( $open, "i wrote this" );
This wont work. I always have problem with the new way of posting variables.
This is what the script results:
Parse error: parse error, unexpected T_VARIABLE in D:\inc shop\leggtilihandlekurv.php on line 9
Line 9 is
$fil = brukere/$_POST['brukernavn']$_POST['passord']
Posted: Wed Aug 28, 2002 9:01 am
by volka
PHP is not bash (or another unix shell)
you have to concatenate strings
Code: Select all
$fil = 'brukere/'.$_POSTї'brukernavn'].$_POSTї'passord'];
or have them replaced within a string 'statement'
Code: Select all
$fil = "brukere/{$_POSTї'brukernavn']}{$_POSTї'passord']}";
Posted: Wed Aug 28, 2002 9:07 am
by Zeceer
Thanx
Posted: Wed Aug 28, 2002 9:17 am
by Zeceer
Code: Select all
<?php
if( $_POSTї'brukernavn']=="" or $_POSTї'passord']=="" )
{
print("Vennligst fyll ut begge felt!");
}
else
{
if( is_file( 'brukere/'.$_POSTї'brukernavn'].$_POSTї'passord'].'.php' )
{
$fil = 'brukere/'.$_POSTї'brukernavn'].$_POSTї'passord'].'.php';
$open = fopen( $fil, 'a' );
fputs( $open, $_POSTї'produkt'] );
}
else
{
print("Du er ikke registrert bruker!");
}
}
?>
Have in ****** can I get an error that says
Code: Select all
Parse error: parse error, unexpected '{' in D:\inc shop\leggtilihandlekurv.php on line 10
I get this error sometimes when using if. But why? And hva can I make it go away?
Posted: Wed Aug 28, 2002 10:21 am
by mikeq
if( is_file( 'brukere/'.$_POST['brukernavn'].$_POST['passord'].'.php' )
) missing parenthesis here.
Get yourself a PHP editor like
PHPEdit this will help highlight things like this.
Posted: Thu Aug 29, 2002 2:24 am
by twigletmac
Code: Select all
<?php
if (empty($_POSTї'brukernavn']) || empty($_POSTї'passord'])) {
print 'Vennligst fyll ut begge felt!';
} else {
if (is_file('brukere/'.$_POSTї'brukernavn'].$_POSTї'passord'].'.php')) {
$fil = 'brukere/'.$_POSTї'brukernavn'].$_POSTї'passord'].'.php';
$open = fopen($fil, 'a');
fputs($open, $_POSTї'produkt']);
} else {
print 'Du er ikke registrert bruker!';
}
}
?>