Page 2 of 2

Posted: Mon May 30, 2005 4:44 pm
by Parody
I'm using Dreamweaver, I just mess up on the ; and ().

One last problem:

Code: Select all

if( $dvd > $rand2 )
(
$success = 1;
)
else
(
$success = 0;
)
The first line of that code is line 14.

The error I get:

Parse error: syntax error, unexpected ';' in c:\program files\apache group\Apache\htdocs\cddvd.php on line 16

Posted: Mon May 30, 2005 4:57 pm
by Skara
Dreamweaver sucks ass too.

You need to use curly brackets, not parentheses:

Code: Select all

if( $dvd > $rand2 )
{
$success = 1;
}
else
{
$success = 0;
}
Though this is a really really lame way to do this, no offense. I'll shorten by steps.

First, no need for brackets unless you want them for single statements.

Code: Select all

if ($dvd > $rand2) $success = 1;
else $success = 0;
Second, for a simple if else that sets a single variable, use a ternary operator:

Code: Select all

$success = ($dvd > $rand2) ? 1 : 0;
Third, since ($dvd > $rand2) evaluates to true or false anyway...

Code: Select all

$success = $dvd > $rand2;
;)

Posted: Mon May 30, 2005 5:00 pm
by Burrito
agreed on the DW statement...you could however use Homesite which is bundled with DW which is a fine editor...in fact my editor of choice simply because of the multiple resource tabs...

not to take this thread off topic or anything 8O

Posted: Mon May 30, 2005 5:04 pm
by Ambush Commander
Actually, I prefer to use brackets, because it's easy to forget to add them later if you want to add extra commands.

Code: Select all

$yes = $_POST['yes'];
if ($yes)
    $command = 0;
$bang = $command;
$foo = $command & $yes;
to

Code: Select all

$yes = $_POST['yes'];
if ($yes)
    $command = 0;
    $piffle = 1;
$bang = $command;
$foo = $command & $yes;
Won't do what you expect.

Posted: Tue May 31, 2005 4:14 am
by Parody
Hopefully this will be the last thing I ask on this topic because I know you are getting annoyed at my stupidity.

The middle line is line 20:

Code: Select all

case "1":
    print "You were successful and got /$"$moneyget"";
    break;
Parse error: syntax error, unexpected T_VARIABLE in c:\program files\apache group\Apache\htdocs\cddvd.php on line 20

Posted: Tue May 31, 2005 4:15 am
by Parody
Can someone give me a link to a site which explains all the errors simply?

I think it would save us all a lot of time :D

Posted: Tue May 31, 2005 4:16 am
by JayBird

Code: Select all

print "You were successful and got /$".$moneyget."";

Posted: Tue May 31, 2005 2:07 pm
by Ambush Commander
Usually, Parse errors aren't much help, you just tend to get a feel of them and then you don't worry about Parse errors. You'd be better off executing the code as often as possible to make sure you didn't make a parse error (one of the great advantages of PHP)