Jump to content

I keep getting a "unexpected t variable" error


Recommended Posts

I know this has to be something simple but I can not figure out for the life of me why this keeps happening. I have used these syntaxs many times before and never got this result.

 

<?php

$ifav = explode(","$ufav);  

foreach($ifav as& $f) {

$cfavor = mysql_query("SELECT * FROM company WHERE cid = '$f'");

while($cfav = mysql_fetch_array($cfavor)) {
	$fcid = $cfav['cid'];
	$fcname = $cfav['cname'];
	$fcity = $cfav['city'];
	$fstate = $cfav['state'];

	$favorite .= '<p>' . $fcid . '. <a target="_blank" href="list.php?cid=' . $fcid . '">' . $fcname . '</a> ' . $fcity . ', ' . $fstate . '</p>';
}

}

?>

 

I have a column in a database where there are comma separated values. I wanted to take those values($ufav) and explode them into separate values where I could then take action on them. For this I ran an explode() then a foreach loop grabbing the exploded values where i queried the database multiple times in order to grab all of the information related to the comma separated values. From there I put the information into a variable and then echoed it out into the page where I required this entire value.

 

Everytime I run this code I get this error:

 

Parse error: syntax error, unexpected T_VARIABLE in /home/content/11/7370211/html/sites/searchapartmentsonline/development/includes/user/fav.php on line 3

 

Which is this line of code:

$ifav = explode(","$ufav);  

 

This has to be simple and has driven absolutely nuts because I can't figure out for the life of me why this code is returning this error. If you could help I would greatly appreciate it!

Thanks!

 

Link to comment
Share on other sites

Sure.  A decent editor that supports PHP should offer color syntax highlighting where errors like that will jump out at you.  In this case you'd need one that has function definitions for the standard libraries.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.