Bentley4 Posted May 26, 2011 Share Posted May 26, 2011 Hi guys, When I insert the following code I get the parsing error "unexpected $end": <?PHP if(isSet($_GET['sid'])) { $con = mysql_connect("localhost","YYYYY", "XXXXX"); if (!$con) {die('Could not connect: ' . mysql_error("oop")); mysql_select_db("YYYYY_testDB") or die(mysql_error()); $totalresult = mysql_query("SELECT * FROM QANDATable"); $num_rows = mysql_num_rows($totalresult); $limit; $counter = 1; while($counter < mysql_num_rows($totalresult)){ $result = mysql_query("SELECT * FROM QANDATable WHERE id = $counter"); $row = mysql_fetch_array($result); echo $row['TSuperQuestion']; if(isSet($_GET['sid'])){ echo "<a href=\"/Code-sandbox.php?sid=".$name."&qandanumber=".$counter."\">next</a>";} echo $row['TQuestion']; echo $row['TAnswer']; $counter++;} } else { echo "<h2>Enter Student Number:</h2>"; echo '<form name="input" action="./Code-sandbox.php" method="GET">'; echo '<input type="text" name="sid"/>'; echo '<input type="submit" value="Submit">'; echo '</form>'; } ?> The code worked before I inserted: if(isSet($_GET['sid'])){ echo "<a href=\"/Code-sandbox.php?sid=".$name."&qandanumber=".$counter."\">next</a>";} Any idea what is wrong here? Link to comment https://forums.phpfreaks.com/topic/237520-any-idea-why-this-code-doesnt-work/ Share on other sites More sharing options...
Adam Posted May 26, 2011 Share Posted May 26, 2011 You generally get that error when you're missing a curly brace somewhere. In your case: if (!$con) {die('Could not connect: ' . mysql_error("oop")); Link to comment https://forums.phpfreaks.com/topic/237520-any-idea-why-this-code-doesnt-work/#findComment-1220537 Share on other sites More sharing options...
Bentley4 Posted May 26, 2011 Author Share Posted May 26, 2011 Thnx, works! Link to comment https://forums.phpfreaks.com/topic/237520-any-idea-why-this-code-doesnt-work/#findComment-1220538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.