dmccabe Posted June 13, 2008 Share Posted June 13, 2008 Ok so I have a line that is throwing this error and its a simple bit of code: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\wamp\www\tooswift\viewplugs.php on line 9 The code is: while($row = mysql_fetch_array($getcats)) { echo "<li><a href=\"viewplugins.php?catid=".$row['id']."\" title=\"View ".$row['name']." category\">".$row['name']"</a></li>"; <--- this is line 9 } It's diving me nuts Edit: I have tried with both \" and ' Link to comment https://forums.phpfreaks.com/topic/110118-argh-cant-find-the-error/ Share on other sites More sharing options...
Barand Posted June 13, 2008 Share Posted June 13, 2008 echo "<li><a href=\"viewplugins.php?catid=".$row['id']."\" title=\"View ".$row['name']." category\">".$row['name']."</a></li>"; ^ | missing "." Link to comment https://forums.phpfreaks.com/topic/110118-argh-cant-find-the-error/#findComment-565120 Share on other sites More sharing options...
PFMaBiSmAd Posted June 13, 2008 Share Posted June 13, 2008 You are missing a concatenation dot . after the second $row['name'] You won't believe how many times this happens when simply concatenating variables with strings. Try the following syntax to see if you like it better (it is less prone to syntax errors) - echo "<li><a href=\"viewplugins.php?catid={$row['id']}\" title=\"View {$row['name']} category\">{$row['name']}</a></li>"; Link to comment https://forums.phpfreaks.com/topic/110118-argh-cant-find-the-error/#findComment-565121 Share on other sites More sharing options...
dmccabe Posted June 13, 2008 Author Share Posted June 13, 2008 Excellent thanks guys, Also lots of thanks for the handy syntax, never knew that before! Now on to the next issue: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\tooswift\viewplugins.php on line 29 if (isset($_GET['catid'])) { $catid = $_GET['catid']; echo $catid; $getplugins = mysql_query("SELECT * FROM plugins WHERE `id` = `$catid`"); echo "<table width=\"100%\"> <th align='center' colspan='5' id='tablehead'>Plugin Details:</th> <tr> <td><b>ID</b></td> <td><b>Name</b></td> <td><b>Author</b></td> <td><b>Home Page</b></td> <td><b>Version</b></td> </tr> "; while($row2 = mysql_fetch_array($getplugins)) { <---- line 29 echo "<tr> <td>{$row2['id']}</td> <td>{$row2['name']}</td> <td>{$row2['author']}</td> <td><a href='{$row2['homepage']}' title='link to {$row2['author']}`s webpage'>Home Page</a></td> <td>{$row2['version']}</td> </tr>"; } echo "</table>"; } Link to comment https://forums.phpfreaks.com/topic/110118-argh-cant-find-the-error/#findComment-565138 Share on other sites More sharing options...
dmccabe Posted June 13, 2008 Author Share Posted June 13, 2008 never mind I got it, thanks again! Link to comment https://forums.phpfreaks.com/topic/110118-argh-cant-find-the-error/#findComment-565146 Share on other sites More sharing options...
DarkWater Posted June 13, 2008 Share Posted June 13, 2008 For the record, you should have OR die (mysql_error()); after all your MySQL queries, so that error doesn't happen. That code will show you the error that occurred in MySQL instead of your code not working and PHP spitting some errors at you. Link to comment https://forums.phpfreaks.com/topic/110118-argh-cant-find-the-error/#findComment-565149 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.