Jump to content

[SOLVED] How do I add a new file to a folder?


ballhogjoni

Recommended Posts

I am having this problem:Fatal error: Call to undefined function: file_put_contents() in /home/cccccc/public_html/ccdfcdfd/popular_cards/index.php on line 13

 

this is my code

 

<?php
$filename = $_POST['file_name'];
$filecontent = $_POST['filecontent'];
if (!empty($filecontent) && !empty($filename)) {
include('config.php');

$query = mysql_query("SELECT * FROM popular_cards") or die(mysql_error());

while ($row = mysql_fetch_array($query)) {
    echo "ID: ".$row["ID"]." & the code is: ".$row["code"]."<br>";
}

$createfile = file_put_contents($filename,$filecontents) or die("Cannot create file"); // problem line

$query1 = "INSERT INTO popular_cards (code) VALUES ('$filecontent')";
mysql_query($query1);

mysql_close();

/*unset($filecontent);
unset($filename);*/
}
?>

'w' = Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length.

If the file does not exist, attempt to create it.

 

I think you must have missed this bit

 

~ Chocopi

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.