wright67uk Posted August 23, 2011 Share Posted August 23, 2011 Im looking to change my page ever so slightly to fit in with my .htaccess file. However I have a syntax issue. Can anybody explain how to fix the below syntax and what i have done wrong so that I can learn from it. <?php $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Cars and Travel' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]); $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href="str_replace(' ','_',$nt[$i])">" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; /*THE SYNTAX ERROR Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' IS IN THE ABOVE LINE*/ $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> This is how it was before; <?php $nt = array(); $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Legal' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> The reason ive altered the top script is that i want my links to be like mysite.com/solicitor opposed to mysite.com/solicitor.php?subtype=solicitor The error is on line 47 which I have labelled in comments PS. I know my php is a bit of a wreck but when I get this syntax issue fixed Ill be working on it. Link to comment https://forums.phpfreaks.com/topic/245532-syntax-error-around-href/ Share on other sites More sharing options...
requinix Posted August 23, 2011 Share Posted August 23, 2011 Compare the before echo "" . ucwords(strtolower (($nt[$i]))) . "" . " "; and the after echo "" . ucwords(strtolower (($nt[$i]))) . "" . " "; Link to comment https://forums.phpfreaks.com/topic/245532-syntax-error-around-href/#findComment-1261092 Share on other sites More sharing options...
wright67uk Posted August 24, 2011 Author Share Posted August 24, 2011 I have changed it to "<a href='" . str_replace(' ','_',$nt[$i]) . " '>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; opposed to; "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; but now the syntax error is saying Parse error: syntax error, unexpected T_VARIABLE in Line 46, there was nothing wrong with line 46 before I edited this line. Link to comment https://forums.phpfreaks.com/topic/245532-syntax-error-around-href/#findComment-1261206 Share on other sites More sharing options...
requinix Posted August 24, 2011 Share Posted August 24, 2011 And what code do you have on and around line 46? Link to comment https://forums.phpfreaks.com/topic/245532-syntax-error-around-href/#findComment-1261450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.