Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Heredoc variable

$
0
0

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?


Viewing all articles
Browse latest Browse all 13200

Trending Articles