passing values with PHP in Apache



ok here's the problem. pages do not seem to be echoing variables


global $strDesc;
global $fileUpload;
global $fileUpload_name;
global $fileUpload_size;
global $fileUpload_type;

// Make sure there is a description and a file path entered

if(empty($strDesc) || $fileUpload=="none")
die("You must enter both a description and file");

// Database connection variables

$fileHandle = fopen($fileUpload, "r");
$fileContent = fread($fileHandle, $fileUpload_size);
$fileContent = addslashes($fileContent);

$sConn = mysql_connect($dbServer, $dbUser, $dbPass)
or die("Couldn't connect to database server");

$dConn = mysql_select_db($dbDatabase, $sConn)
or die("Couldn't connect to database $dbDatabase");

$dbQuery = "INSERT INTO myBlobs VALUES";
$dbQuery .= "(0, '$strDesc', '$fileContent', '$fileUpload_type')";

mysql_query($dbQuery) or die("Couldn't add file to database");


when i post to this PHP file from the following form I get the error "You must enter both a description and file"

<head><title>Upload files here</title></head>


<form enctype="multipart/form-data" name="frmUploadFile" action="grabfile.php" method="post">
<input type="text" name="strDesc" size="20" maxlength="50" /><br />
<input type="file" name="fileUpload" size="20"> <br/>
<input type="submit" name="cmdSubmit" value="Upload"><br />


This code works as is one my University's server. When the same code is executed on my server it does not do what it should. The problem is that the page is not getting the variables. Any ideas anyone? I'm wondering if there is some configuration that I need to change. FYI I'm running Fedora Core 4 with Apache and PHP4

Thanks in advanced. Any suggestions would be greatly appreciated.
Try using $_POST superglobal variable.
Your school server probably have PHP's register_globals directive set to On.
So seems that you have it Off in your server (and that's the best option - for security reasons).
So... you will now need to use the superglobal variables.


$strDesc = $_POST['strDesc'];
$fileUpload = $_POST['fileUpload'];
$fileUpload_name = $_POST['fileUpload_name'];
$fileUpload_size = $_POST['fileUpload_size'];
$fileUpload_type = $_POST['fileUpload_type'];

// The rest like it is