Newbee question




Can anybody point me in the right direction Im very new to php and any help would be appreciated

Whats wrong with this snippt of code??

echo '<img src="catalog/affiliates/$_SERVER['SERVER_NAME']/oscommerce.gif">' ;


I get the following error

unexpected T_STRING, expecting ',' or ';'

Thanks in advance
Your string has single quotes at the ends AND you have single quotes inside your string... thats bad :)

Try this...

echo '<img src="catalog/affiliates/'.$_SERVER['SERVER_NAME'].'/oscommerce.gif">' ; 


I'm pretty sure that'll fix your problem :D
The main difference between using single quotes (') and double quotes(") is that single quotes will quote a string exacty:
print 'The variable value is $value'; will output The variable value is $value
Double quotes will parse the string for variables and replace them, therefore (assuming $value = 50) using double quotes for the same line will output The variable value is 50

You also can't use the same style quote within your string (otherwise the parser wouldn't know where your string ended). If you have to use the same quote, escape it with a backslash first so it's not taken literally (or use double quotes if you're using single - I personally find using double quotes far easier)
eg print 'That's Amazing' - Wrong
print 'That\'s Amazing' - Correct
print "That's Amazing" - Even better

You also cannot use an array variable within a string, unless you either access it directly in PHP (ie close the string, concatenate the variable and reopen the string) or enclose it within curly braces
eg - print "The value is $_SESSION['value']"; - Wrong
print "The value is {$_SESSION['value']}"; - OK
print "The value is ".$_SESSION['value']; - Much better