Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 18th, 2011, 06:21 AM
Registered User
 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default what could be wrong with this code?

Code:
if($_POST['color'] == 'red')
	{
		print '<p style = "color:red;">Red is your favourite color</p>;'
	}
	elseif($_POST['color']== 'yellow')
	{
		print '<p style = "color:yellow;">Yellow is your favourite color</p>';
	}
	elseif($_POST['color'] =='green')
	{
		print '<p style = "color:green;">Green is your favourite color</p>';
	}
	elseif($_POST['color'] == blue)
	{
		print '<p style = "color:blue;">Blue is your favourite color</p>';
	}
	else
	{
		print '<p class = "error">Select your favourite color</p>';
	}
  #2 (permalink)  
Old August 23rd, 2011, 09:47 AM
Friend of Wrox
Points: 651, Level: 9
Points: 651, Level: 9 Points: 651, Level: 9 Points: 651, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Location: North East UK
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

Semi-colon on line 3 is inside the ' when it should be outside.

blue on line 13 should be in quotes like the other colours.


Similar Threads
Thread Thread Starter Forum Replies Last Post
There is something wrong in my code? Cade_Feng BOOK: Professional C# 2008 ISBN: 978-0-470-19137-8 3 March 4th, 2011 02:17 AM
what's wrong with my code? DyerOppenheimer BOOK: Beginning Ajax with ASP.NET 0 January 7th, 2008 08:46 AM
What's wrong with this code jack123 SQL Server 2000 4 July 11th, 2007 12:09 PM
What is wrong with this code? SaharaWizard VB Databases Basics 2 January 28th, 2006 08:20 AM
what's wrong with this code? miguel.ossa ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2004 11:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.