I posted this on the other forum, but I couldn't quite understand and solve the problem.
I am pretty new at managing and building functions, i'm kinda beginning to understand how they work.
this is a function inside a php script:
<?
function submit_final($filename,$image,$stars,$plot,$poster)
{
// from here this was a php file called submitfinal.php now it's part of this function
$date = date("M d, Y");
$conn = db_connect();
$time = time();
$sql = "insert into imagesdb (filename, image, stars, plot, poster) values ('$filename', '$image', '$stars', '$plot', '$poster')";
$result = mysql_query($sql,$conn);
if (!$result) {
print "Error on database while executing<PRE>$sql</PRE>";
print mysql_error();
exit;
}
if ($poster_name != "")
{
move_uploaded_file("$poster", "/home/wwsite/public_html/images/images/$poster_name") or die("Couldn't Upload Your File.");
} else {
die("You haven't uploaded any file!");
}
if (!$story)
{
$story = mysql_insert_id();
$sql = "update imagesdb set poster = '$poster_name' where id = $story";
$result = mysql_query($sql,$conn);
}
}
?>
I had this code working in a separate file, along with its upload form and it worked perfectly, but now that I joined them both as functions in a single file, I get the following error:
Warning: Missing argument 1 for submit_final() in /home/tucuadre/public_html/test/functions.php on line 339
Warning: Missing argument 2 for submit_final() in /home/tucuadre/public_html/test/functions.php on line 339
Warning: Missing argument 3 for submit_final() in /home/tucuadre/public_html/test/functions.php on line 339
Warning: Missing argument 4 for submit_final() in /home/tucuadre/public_html/test/functions.php on line 339
Warning: Missing argument 5 for submit_final() in /home/tucuadre/public_html/test/functions.php on line 339
You haven't uploaded any file!
As a result, there is no insersion on the database and no image is uploaded.
As I said before, what surprises me the most is that the code outside the function worked perfectly.
I call the function at another file as follows:
<?php
include('variablesmov.php');
include('functions.php');
submit_final();
?>
the form is a normal form
<?php
function createimage()
{
// etc....
}
<input type="hidden" name="MAX_FILE_SIZE" value="300000">
<input type="file" name="poster">
<input type="submit" value="Enviar" name="submit2">
<?php
}
?>
i'd appreciate any help because i've had a couple of days strugling with this code.