Jump to content


Photo

error


  • Please log in to reply
8 replies to this topic

#1 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 June 2006 - 04:29 AM

echo <a href=\"$row['link'].'\">$row['thumb'].'</a>;

gives me

Parse error: syntax error, unexpected '<', expecting ',' or ';' in /xxx/xxx/xx/xx/xx/thumbnail.php on line 23

any idea how to fix

#2 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 12 June 2006 - 04:32 AM

You have your quotes messed up.

<?php
echo '<a href="' . $row['link'] . '">' . $row['thumb'] . '</a>';
?>

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#3 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 June 2006 - 04:36 AM

worked, thanks. btw, how do you know where the quotes go and how to set em up properly?

#4 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 12 June 2006 - 04:47 AM

Ok. Single quotes and double quotes have a slight difference in PHP. There is more than one way to code your example.

Code 1:
<?php
echo "<a href=\"$row['link']\">$row['thumb']</a>";
?>

Code 2:

<?php
echo '<a href="' . $row['link'] . '">' . $row['thumb'] . '</a>';
?>

When you use double quotes while echoing a string, you don't need to concatenate the string with your variables. You can just echo them within the string. But with this technique, you do need to escape other double quotes in the string with a backslash(\).

If you use single quotes while echoing a string, you have to concatenate(.) the string together with the variables, as in Code 2.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#5 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 June 2006 - 04:55 AM

i see. well i ran into another error. its different.

    echo "' . $row['name'] . '"
            <br>
            <table border='0' width='100%' id='table1'>
                <tr>";

it generated this error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in xx/x/xxx/x/xxx on line 12

can anyone help fix pleaseeee

#6 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 12 June 2006 - 05:01 AM

<?php
echo "$row['name']
            <br>
            <table border='0' width='100%' id='table1'>
                <tr>";
?>

If you use double quotes to echo with, you DO NOT need to concatenate your variable into your string.

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#7 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 June 2006 - 05:02 AM

ah, i tried that, but then i got the exact same error as well.

#8 jeremywesselman

jeremywesselman
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts
  • LocationIndependence, KY

Posted 12 June 2006 - 05:06 AM

Try this:

<?php
echo $row['name'] . "<br><table border='0' width='100%' id='table1'><tr>";
?>

[!--coloro:#990000--][span style=\"color:#990000\"][!--/coloro--]Jeremy[!--colorc--][/span][!--/colorc--]

#9 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 June 2006 - 05:09 AM

yeah works, thanks ! :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users