Hey thanks again ClarkF1,
I did what you said but my pictureID still doesn't change, Code below:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input name="uploadedfile" type="file" /><br />
<input type="submit" value="submit" />
<input type="hidden" name="hidden" value="h3"/>
</form>
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input name="uploadedfile" type="file" /><br />
<input type="submit" value="submit" />
<input type="hidden" name="hidden" value="h4"/>
</form>
<?
// Connect to DATABASE
$conn = mysql_connect("localhost","*****","*****");
// Connect to Table and stores connection as variable: conn
$db = mysql_select_db("*****_academicPrograms", $conn);;
// Queries the user input data with the database data
$result = MYSQL_QUERY("SELECT * from academicPrograms")
or die ("Data not found");
// Gets boolean value of whether the query worked
$worked = mysql_fetch_array($result);
// Gets all values from table and stores them as variables
$pictureID = $worked[pictureID];
// ***************************************** END PHP CODE
switch ($_POST['hidden']) {
case 'h3':
$result = MYSQL_QUERY("UPDATE academicPrograms SET pictureID = 1");
break;
case 'h4':
$result = MYSQL_QUERY("UPDATE academicPrograms SET pictureID = 2");
break;
default:
print 'None of the cases reached.';
break;
} // End: switch ($_POST['hidden'])
?>
Could the problem be in my uploader.php?
This is it below:
<?
// Connect to DATABASE
$conn = mysql_connect("localhost","*****","******");
// Connect to Table and stores connection as variable: conn
$db = mysql_select_db("******_academicPrograms", $conn);;
// Queries the user input data with the database data
$result = MYSQL_QUERY("SELECT * from academicPrograms")
or die ("Data not found");
// Gets boolean value of whether the query worked
$worked = mysql_fetch_array($result);
// Gets all values from table and stores them as variables
$pictureID = $worked[pictureID];
// Outputs for testing purposes
echo "the picture ID is ".$pictureID;
?>
<?
// Connects to Database for uploading image through FTP
$ftpconn = ftp_connect("*****") or die("Could not connect");
ftp_login($ftpconn,"*****","*****");
// The Directory the file will be placed
$target_path = "Images/";
if($pictureID = 1){$uniqueName = "1_img.jpg";}
if($pictureID = 2){$uniqueName = "2_img.jpg";}
//Assigns a the path and the name together
$uniqueID= $target_path.$uniqueName;
//Moves to temp file to the targetpath
$_FILES['uploadedfile']['tmp_name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uniqueID)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
Hmm... but uploader shouldn't matter right? Since the problem comes from the form. I've tried changing double quotes from quotes and back, nothing. I checked to see if my database worked, and used a simple button to send values to it, that worked fine. For some reason, combining uploading images and sending values to the database is giving me problems.
Again, the images upload fine, whether from one box or the other, the pictureID is currently set as 1, and refuses to change.
ClarkF1, thanks again for your help