PHP - File_put_contents
i need a little help with the code below with the file name at the end
file_put_contents('/home/sambobi/public_html/bob/b_images/$id.jpg', $content); the variable $id id not working :/ Similar TutorialsI'm trying to create a an admin backend page for a food truck website. They need to be able to update their menu on the page pretty frequently, so I created a page that would use file_put_contents() to replace the text in an html file that I would display on the page in iframes, this would be the menu text. I have everything coded and working except file_put_contents() will not work at all. I'm using Go Daddy hosting, and they said that I could create an .ini file turning whatever setting it is that controls file_put_contents(), but I have tried numerous setting and can't get anywhere. This is the php code I'm working with: <?php $menu_text = $_POST['updateleft']; $html_begin = "<html><body><table bgcolor='black'><td><tr><font size='5' color='yellow'>"; $html_end = "</font></tr></td></table></body></table></html>"; $final_page = $html_begin.$menu_text.$html_end; $file_name = 'menuleft.html'; file_put_contents($final_page,$file_name); header("location:http://www.timbertheband.com/menu/menuadmin.html"); ?> and this is the admin page, not working: http://www.timbertheband.com/menu/menuadmin.html I'm not married to file_put_contents() or even this method so any suggestions at all I'm open to hearing. I've been working on this problem over a month now and I really need to get it figured out. The idea is I just need to have a way for them to update their menu and I don't want to create a database or anything, just keep it as simple as possible. I'm attempting to have a script that when complete, will access my email account, add all the email addresses of senders to a database (just a text file for now), and mail the list out once a week. At the moment, however, I am stuck. I'm using put_file_contents to try and add these addresses to a text file, but it only writes one email address. My code is as follows. <?php $imap = imap_open("{imap.gmail.com:993/imap/ssl}INBOX","xxx@gmail.com", "xxx" ); $message_count = imap_num_msg($imap); for ($i = 1; $i <= $message_count; ++$i) { $header = imap_header($imap, $i); if (isset($header->from[0]->personal)) { $personal = $header->from[0]->personal; } else { $personal = $header->from[0]->mailbox; } $email = "$personal <{$header->from[0]->mailbox}@{$header->from[0]->host}>"; $fromaddr = $header->from[0]->mailbox . "@" . $header->from[0]->host; echo "$fromaddr <br>"; } $file = 'database.txt'; $current = file_get_contents($file); $current .= ($header->from[0]->mailbox . "@" . $header->from[0]->host); file_put_contents($file, $current); imap_close($imap); ?> The echo shows all the email addresses when I load the page, but when I try to write it, it only writes the last one displayed. How do I resolve this issue? Thank you in advance. Just trying to create a simple form that will let you enter a message that will get written to a text file. Code for SetMessage.php: Code: [Select] <?php if($_SERVER['REQUEST_METHOD'] != 'POST') { ?> <form method="POST" action="setmessage.php" name="setmessage"> <p>Message to Display:<Input type="text" name="message" size="50"></p> <p><input type="submit" value="Submit" name="submit"></p> </form> <?php } else { //Writes the contents of the message to a file echo file_put_contents('message.txt', $_POST['message']); } ?> When submitting, I get the error "Call to undefined function: file_put_contents() on line 16" |