tzv111 Posted November 15, 2009 Share Posted November 15, 2009 I have a function and within that some code which is recalling some information from a database, however i keep getting an error stating Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_u003753/public_html/assesment/functions.php on line 61 function guestList(){ $guessContent = <<<GUESTS <div id="left"> <h2>Guestlist created</h2> include 'database_conn.php'; $sql = "SELECT * FROM guestlist"; $queryresult = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($queryresult)){ $guestID = $row['guestID']; $surName= $row['surName']; $firstName = $row['firstName']; $number = $row['number']; echo "guestID: $guestID<br />"; echo "surName: $surName<br />"; echo "firstName: $firstName<br />"; echo "number: $number<br />"; echo "<hr />"; </div> GUESTS; $guestContent .= "\n"; return $guestContent; } Line 61 is $guestID = $row['guestID']; any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/181612-i-cant-see-what-the-error-is/ Share on other sites More sharing options...
mrMarcus Posted November 15, 2009 Share Posted November 15, 2009 improper usage of the HEREDOC syntax by trying to execute functions within the syntax, ie. mysql_query(), etc. Quote Link to comment https://forums.phpfreaks.com/topic/181612-i-cant-see-what-the-error-is/#findComment-957944 Share on other sites More sharing options...
tzv111 Posted November 15, 2009 Author Share Posted November 15, 2009 I have tried placing it outside of the HEREDOC this fixes that initial problem, but I then don't know how to wrap the divs around the database retrieval code. I have tried many different methods but If I place the Divs outside of a HEREDOC they produce errors Quote Link to comment https://forums.phpfreaks.com/topic/181612-i-cant-see-what-the-error-is/#findComment-958002 Share on other sites More sharing options...
wildteen88 Posted November 15, 2009 Share Posted November 15, 2009 You only need to use heredoc within the while loop. function guestList() { $guessContent = <<<GUESTS <div id="left"> <h2>Guestlist created</h2> GUESTS; include 'database_conn.php'; $sql = "SELECT * FROM guestlist"; $queryresult = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($queryresult)) { // start while loop $guestID = $row['guestID']; $surName= $row['surName']; $firstName = $row['firstName']; $number = $row['number']; $guestContent .= <<<GUESTS guestID: $guestID<br /> surName: $surName<br /> firstName: $firstName<br /> number: $number<br /> <hr /> </div> GUESTS; } // end while loop $guestContent .= "\n"; return $guestContent; } Quote Link to comment https://forums.phpfreaks.com/topic/181612-i-cant-see-what-the-error-is/#findComment-958010 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.