[!--quoteo(post=378652:date=May 31 2006, 05:24 AM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ May 31 2006, 05:24 AM) [snapback]378652[/snapback][/div][div class=\'quotemain\'][!--quotec--] Can someone see if they can see where this code is going wrong? I'm trying to explode a variable $genre then each value in the new array needs to be put back into an SQL query - where i attempted to insert a new variable ($finalString) into the sql statement. [code] if (isset($_SESSION['username'])) { $genre = $_GET['genre']; // retrieve passed variable //open connection $conn = mysql_connect("localhost", "admin", "adm1n"); mysql_select_db("project",$conn); $sql = "select USERNAME, PASSWORD, F_NAME, FAVOURITES, ADMIN, DOB from users where USERNAME = '$_SESSION[username]'"; $check = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($check)) { $genre = ($row['FAVOURITES']); $genre2 = explode(', ', $genre); } $count = count($genre2); $i=0; $finalString = NULL; do { if (i > 0) $String = " OR F_TYPE LIKE '%"; $finalString = $String + $genre2[$i]; $String2 = "%'"; $finalString = $finalString + $String2; $i++; else $String = "F_TYPE LIKE '%"; $finalString = $String + $[i]; $String2 = "%'"; $finalString = $finalString + $String2; $i++; //echo "The number is " . $i . "<br />"; } while ($i<$count); $query = "SELECT ID_NO, F_NAME, F_DIRECTOR, F_REVIEWER, F_DATETIME, F_TYPE, F_SUMMARY, F_REVIEW, F_SCORE FROM films WHERE $finalString ORDER BY F_DATETIME LIMIT 1, 20 ";[/code] At the moment its picking out an error at 'else'... Parse error: parse error, unexpected T_ELSE Can someone see why? Thanks d [/quote] It seems like you're not encapsulating the if and else statements in { ... }, them squiggly things