16

I am very new to PHP and have no idea why this is happening, I have looked at other online items, however I just cannot seem to see why I am getting this error.

<?php
include_once('assets/libs/posicloud/posicloud.php');

    $cloud=new posicloud();
    $out='';
    foreach ($cloud->list_templates() as $key=>$template)
    {
$out.='<option value=''.$key.'">'.$value["name"].';
    }
  return $out;
?>

Thankyou for any help!

3
  • 1
    Thanks, apologies but I am very new, I have read the error messages but did not understand them, thats why I posted here to see if someone could help me understand my issue.
    – user1842567
    Commented Nov 26, 2012 at 13:30
  • There's something wrong with your quotes notation. As this is a very important aspect of PHP (or programming in general), I recommend reading some more about it first before we give you a bite-sized answer. For example: trans4mind.com/personal_development/phpTutorial/quotes.htm Commented Nov 26, 2012 at 13:44
  • I was receiving this error and had to convert the file line separators from CF to CRLF.
    – Enkode
    Commented Aug 30, 2015 at 5:43

5 Answers 5

22

When you're working with strings in PHP you'll need to pay special attention to the formation, using " or '

$string = 'Hello, world!';
$string = "Hello, world!";

Both of these are valid, the following is not:

$string = "Hello, world';

You must also note that ' inside of a literal started with " will not end the string, and vice versa. So when you have a string which contains ', it is generally best practice to use double quotation marks.

$string = "It's ok here";

Escaping the string is also an option

$string = 'It\'s ok here too';

More information on this can be found within the documentation

2
  • Please remember to upvote/accept an answer if it worked for you. It'll guarantee future help down the line :-)
    – Rawkode
    Commented Nov 26, 2012 at 14:22
  • Ticked for most descriptive and helpful answer.
    – user1842567
    Commented Nov 26, 2012 at 14:59
2

Wrong quoting: (and missing option closing tag xd)

$out.='<option value="'.$key.'">'.$value["name"].'</option>';
1
'<option value=''.$key.'">'

should be

'<option value="'.$key.'">'
1
  • 1
    …or sprintf( '<option value="%s">', $key );
    – feeela
    Commented Nov 26, 2012 at 13:26
1

You have a sintax error in your code:

try changing this line

$out.='<option value=''.$key.'">'.$value["name"].';

with

$out.='<option value="'.$key.'">'.$value["name"].'</option>';
0
$out.='<option value="'.$key.'">'.$value["name"];

me funciono con esta

"<a  href='javascript:void(0)' onclick='cargar_datos_cliente(\"$row->DSC_EST\")' class='button micro asignar margin-none'>Editar</a>";