PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Aug 28, 2002 8:57 am
$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']
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Aug 28, 2002 9:01 am
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']}";
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Aug 28, 2002 9:07 am
Thanx
Zeceer
Forum Contributor
Posts: 136 Joined: Fri Aug 02, 2002 5:10 am
Location: Norway
Post
by Zeceer » Wed Aug 28, 2002 9:17 am
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?
mikeq
Forum Regular
Posts: 512 Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland
Post
by mikeq » Wed Aug 28, 2002 10:21 am
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.
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Thu Aug 29, 2002 2:24 am
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!';
}
}
?>