Juniorflip
-
Posts
8 -
Joined
-
Last visited
Never
Posts posted by Juniorflip
-
-
I need to load a variable into an array here is my code so far
[code]
$ourFileName2 = $ourFileName;
Function create_xml() {
$files = array('header.xml',$ourFileName2,'footer.xml');
foreach($files as $file)
{
$contents[] = file_get_contents($file);
}
$fp = fopen('new_file.xml','w+');
fwrite($fp,join("\n",$contents));
fclose($fp);
}
create_xml();[/code] -
Ok I am on the last part YAY!!! I just can't figure this last one out. if I put in the array the actual body name it work however if I put in a variable it doesn't here is the excerpt and the full php
When I use this code it doesn't bring over the XXXXbody.xml
[code]$ourFileName2 = $ourFileName;
Function chmod_xml() {
chmod('1610body.xml', 0777); // octal; correct value of mode
}
chmod_xml();
Function create_xml() {
$files = array('header.xml',$ourFileName2,'footer.xml');
foreach($files as $file)
{
$contents[] = file_get_contents($file);
}
$fp = fopen('new_file.xml','w+');
fwrite($fp,join("\n",$contents));
fclose($fp);
}
create_xml();
[/code]
However if I manual type it in it works!!! any help would be appreciated
[code]<?php
/******START CODE EXTRACT******/
if(!function_exists("file_get_contents"))
{
function file_get_contents($f = null)
{
if(is_null($f)) return null;
return implode("", file($f));
}
}
/*******END CODE EXTRACT*******/
$ourFileName = $campaign."body.xml";
if (file_exists($ourFileName)) {
$fh = fopen($ourFileName, 'a');
} else {
$fh = fopen($ourFileName, 'w') or die("can't open file");
}
$record = "<record>";
$campaignid = "<campaignid>";
$experienceid = "<experience>";
$noteid = "<note>";
$nameid = "<name>";
$record2 = "</record>";
$campaignid2 = "</campaignid>";
$experienceid2 = "</experience>";
$noteid2 = "</note>";
$nameid2 = "</name>";
fwrite($fh, $record);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $campaignid);
fwrite($fh, $campaign);
fwrite($fh, $campaignid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $experienceid);
fwrite($fh, $experience);
fwrite($fh, $experienceid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $noteid);
fwrite($fh, $note);
fwrite($fh, $noteid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $nameid);
fwrite($fh, $name);
fwrite($fh, $nameid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $record2);
fclose($fh);
$ourFileName2 = $ourFileName;
Function chmod_xml() {
chmod('1610body.xml', 0777); // octal; correct value of mode
}
chmod_xml();
Function create_xml() {
$files = array('header.xml','1610body.xml','footer.xml');
foreach($files as $file)
{
$contents[] = file_get_contents($file);
}
$fp = fopen('new_file.xml','w+');
fwrite($fp,join("\n",$contents));
fclose($fp);
}
create_xml();
?>[/code] -
because I am trying to join the file to two other file to make an xml here is my source
[code]<?php
/******START CODE EXTRACT******/
if(!function_exists("file_get_contents"))
{
function file_get_contents($f = null)
{
if(is_null($f)) return null;
return implode("", file($f));
}
}
/*******END CODE EXTRACT*******/
$ourFileName = $campaign."body.xml";
if (file_exists($ourFileName)) {
$fh = fopen($ourFileName, 'a');
} else {
$fh = fopen($ourFileName, 'w') or die("can't open file");
}
$record = "<record>";
$campaignid = "<campaignid>";
$experienceid = "<experience>";
$noteid = "<note>";
$nameid = "<name>";
$record2 = "</record>";
$campaignid2 = "</campaignid>";
$experienceid2 = "</experience>";
$noteid2 = "</note>";
$nameid2 = "</name>";
fwrite($fh, $record);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $campaignid);
fwrite($fh, $campaign);
fwrite($fh, $campaignid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $experienceid);
fwrite($fh, $experience);
fwrite($fh, $experienceid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $noteid);
fwrite($fh, $note);
fwrite($fh, $noteid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $nameid);
fwrite($fh, $name);
fwrite($fh, $nameid2);
fwrite($fh, "\n");
fwrite($fh, "\n");
fwrite($fh, $record2);
fclose($fh);
$ourFileName2 = $ourFileName;
Function create_xml() {
$files = array('header.xml',$ourFileName2,'footer.xml');
foreach($files as $file)
{
$contents[] = file_get_contents($file);
}
$fp = fopen('new_file.xml','w+');
fwrite($fp,join("\n",$contents));
fclose($fp);
}
create_xml();
?>[/code]
It will create XXXXbody.xml and it will create new_file.xml. new_file.xml will have header and footer in it. but it will not have body.xml in it. I am wondering if because it can not access the file -
Is there a function that can make a file 777. I am trying to create a file and then make it chmod to 777 so I can join it with another file?
-
is there a reason why I am getting this error?
[code]Fatal error: Call to undefined function: get_file_contents() in /var/www/html/cs/EmailLauncher/logs/write.php on line 55[/code] -
So if I wanted to make a function it would go like this
[code]
Function create_greet {
$header = get_file_contents('header.txt');
$body = get_file_contents('body.txt');
$footer = get_file_contents('footer.txt');
if ($header === false) die("Couldn't read header.txt\n");
$greeting_fp = fopen('greeting.txt', 'w');
fwrite($greeting_fp, $header);
fwrite($greeting_fp, $body);
fwrite($greeting_fp, $footer);
fclose($greeting_fp);
}
create_greet();
[/code] -
Hopefully this is a simple function to do but I am looking to join 3 external file and output to a single file
example
header.txt = hello
body.txt = welcome
footer.txt = goodbye
I need a php function that will open all three text file and print the value to a new text file
example
greeting.txt = hello
welcome
goodbye
Is this possible to do?
Thanks in advance
Required Field
in PHP Coding Help
Posted
[code]<html>
<head>
<body>
<h4>EmailLauncher Note Form</h4>
<form action="write.php" method="post"">
Campaign: <input name="campaign" type="text" value=""/>
<?php
if(trim($_POST['campaign']) == "") {
die("no value was entered");
}
?>
<select name="experience">
<option>Good</option>
<option>So So</option>
<option>Bad</option>
<option>Cancelled</option>
</select>
<br><br>
<select name="note">
<option>Yes</option>
<option>No</option>
<option>Supersave</option>
</select><br><Br>
Customer Lead Name: <input name="name" type="text" value=""/>
<input type="submit" />
</form>
</body></html>[/code]
However it automatically kill it right away. Is there a way to have the function execute on button click before going to write.php