Search the Community
Showing results for tags 'heredoc'.
-
I have a php file that has this in it... //Make logChatInput.php $dataBase = "users"; $logChatInput = fopen($newDir."/logChatInput.php", "w"); $logChatInput_contents = <<<EOD <?php $chatInput = addslashes($_GET["chatInput"]); date_default_timezone_set('America/Chicago'); $time = date('g:i A'); $crappychat_service = mysql_connect("localhost", "root", ""); mysql_select_db("{$dataBase}", $crappychat_service); $sql = "INSERT INTO messages (Message) VALUES('".$chatInput."')"; mysql_query($sql, $crappychat_service); ?> EOD; fwrite($logChatInput, $logChatInput_contents); fclose($logChatInput); My problem is I want ONLY $dataBase to be recognized as a the value it holds and not anything else. The php is giving an error because I don't have $chatInput declared outside the EOD. I only want the $dataBase variable to be associated with the current PHP file and not the one being written, so I put it in curly braces, but it still recognizes other "variables". How would have it only recognize $dataBase in the EOD?
-
Having a parse error with my heredoc statement , so what is wrong with it ??? //retrieve information $query = 'SELECT movie_name, movie_year, movie_director, movie_leadactor, movie_type FROM movie ORDER BY movie_name ASC, movie_year DESC'; $result = mysql_query($query, $db) or die(mysql_error($db)); //determine the no. of rows in returned result $num_movies = mysql_num_rows($result); $table = <<<ENDHTML <div style="text-align: center" > <h2> Movie Review Database </h2> <table border="1" cellpadding="2" cellspacing="2" style="width: 70%; margin-left: auto; margin-right: auto;"> <tr> <th>Movie Title</th> <th>Year of release</th> <th>Movie Director</th> <th>Movie Lead Actor</th> <th>Movie Type</th> </tr> ENDHTML; // loop through the result while ($row = mysql_fetch_assoc($result)) { extract($row); $table .= <<<ENDHTML <tr> <td>$movie_name</td> <td>$movie_year</td> <td>$movie_director</td> <td>$movie_leadactor</td> <td>$movie_type</td> </tr> ENDHTML; } $table .= <<<ENDHTML </table> </div> <p align="center" >$num_movies Movies </p> </div> ENDHTML; echo $table; parse error : 'Parse error: syntax error, unexpected T_SL in table.php on line 22'