My slightly bad PHP skills...

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
Domnio





Posts: 199
Joined: Sun Jul 16, 2006 3:44 pm
Location: Earth
Contact:

My slightly bad PHP skills...

Post by Domnio »

I'm doing an "if statement" but idk what i'm doing wrong here...

I'm tring to make $answer = 17 without declaring $answer as 17 using math but it's not working all that well... it's either my bad php skills or my bad math skills lol I can't really tell

can anyone see what I'm doing wrong? The problem I'm tring to solve is
2x + 7 and the answer should come out 17....

Code: Select all

<?php

// Practice so I don't forget how to do PHP

// Declare variables

$number = "2";

$number1 = "7";

$letter = "x";

$letter * $number = "5";

$two_x = $number * $letter;

$two_x + $number1 = $answer;

// If statement (hopefully this will work >.<)

if ( $answer = $two_x + $number1 )
{
	
	echo ( $answer );
	
}
else
{
	
	echo ( "Wrong... the right answer is: " . $answer );
	
}

?>
My else statement was triggered so I'm guessing somewhere in my PHP I messed up....
RaVNzCRoFT removed my signature because it contained too many lines of text. I'll read the rules next time.
Post Reply