Variable Problem

Ask about a PHP problem here.
Post Reply
toqi786
Posts: 9
Joined: Mon May 16, 2011 12:43 pm

Variable Problem

Post by toqi786 »

Hey

I have a problem, I am using the following code
[line 141]if($Availability==1) {
			$Price = $row['Price'];
			$Price = echo "ONLY £$Price";
		} else {
			$Price = echo '<img src="../img/sold.png" width="163" height="122">';
		}
I am using this code and i am getting the following error
Parse error: syntax error, unexpected T_ECHO in /home/a5872994/public_html/pages/stocklist.php on line 143
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Variable Problem

Post by jacek »

You cant set a variable equal to an echo statement :?

What are you trying to do here ?
Image
toqi786
Posts: 9
Joined: Mon May 16, 2011 12:43 pm

Re: Variable Problem

Post by toqi786 »

I have like a stocklist table, if the availability in the database = 1 [its either 1 or 0] then i want to show the price if not i want to show the sold.png i have created to show that it is sold and not available!
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Variable Problem

Post by jacek »

Did you mean to do this then...
if($Availability==1) {
     $Price = $row['Price'];
     $Price = "ONLY £$Price";
} else {
     $Price = '<img src="../img/sold.png" width="163" height="122">';
}

echo $Price;
??
Image
toqi786
Posts: 9
Joined: Mon May 16, 2011 12:43 pm

Re: Variable Problem

Post by toqi786 »

yes it was thanx! all i had to do is get rid of the echo lol :D thanx for the help man!!
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Variable Problem

Post by jacek »

toqi786 wrote:yes it was thanx! all i had to do is get rid of the echo lol :D thanx for the help man!!
no problem :D
Image
Post Reply