PHP forums, MySQL forums, Web Development resources

Home PageHome    PHP ResourcesTopic List    FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups 
 RegisterRegister
    ProfileProfile    Log in to check your private messagesLog in to check your private messages    Download the RSS Reader RSS Feed Download the RSS Reader RSS for this forum Log inLog in 

PHP Forum :: MySQL Forum :: Java Script Forum



Question regarding PHP and MySQL

 
Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General
View previous topic :: View next topic  
Author Message
CraigH



Joined: 17 Oct 2007
Posts: 2

PostPosted: Wed Oct 17, 2007 8:50 pm    Post subject: Question regarding PHP and MySQL Reply with quote

First off, hello everyone.. My first post..

I am working on a form in PHP that uses a MySQL DB. Part of my form contains some text files, the second part is a file upload area. I have mixed some code together so that on submit it populates the DB with data from the text fields and then uploads the files to their locations.. My issue is, I would also like to take the file name from the upload box (not the entire path, just the file.extention) and place that information into a field in the DB as well. I have tried submitting the upload field name as text to the DB but that did not work.. Any ideas? Here is that section of code..

[code:1]
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO itissues (name, `date`, computer, problem) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['date'], "text"),
GetSQLValueString($_POST['computer'], "text"),
GetSQLValueString($_POST['problem'], "text"));

mysql_select_db($database_helpdesk, $helpdesk);
$Result1 = mysql_query($insertSQL, $helpdesk) or die(mysql_error());

$insertGoTo = "records.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
// File Upload Code
$uploaddir = 'uploads/flow/';
$uploadfile = $uploaddir . basename($_FILES['userfile1']['name']);
$uploaddir2 = 'uploads/fac/';
$uploadfile2 = $uploaddir2 . basename($_FILES['userfile2']['name']);
$uploaddir3 = 'uploads/bit_maps/';
$uploadfile3 = $uploaddir3 . basename($_FILES['userfile3']['name']);

echo "<p>";

if (move_uploaded_file($_FILES['userfile1']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}

if (move_uploaded_file($_FILES['userfile2']['tmp_name'], $uploadfile2)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}

if (move_uploaded_file($_FILES['userfile3']['tmp_name'], $uploadfile3)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Upload failed";
}

echo "</p>";
echo '<pre>';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
}
[/code:1]

Thanks for any help!
Craig
Back to top
View user's profile Send private message
lostboy



Joined: 02 May 2004
Posts: 6059
Location: toronto, canada

PostPosted: Thu Oct 18, 2007 2:40 am    Post subject: Reply with quote

what part wasn't working...

$_FILES['userfile1']['name'] should give you the name of the file
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Display posts from previous:   
WeberTrivia Questions WeberTrivia Questions
 Think you are smart? Prove it!. Try your skills with these questions :
 WeberTrivia QuestionsRecursive arrays and multi-dimensional arrays are one and the same. (PHP and MySQL)
 WeberTrivia QuestionsThe \"cache_dir\" tag of the squid configuration has a default of /var/spool/squid. (Linux)

WeberTrivia Questions



Post new topic   Reply to topic    WeberForums.com Forum Index -> PHP General All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
PHP Forum :: MySQL Forum :: Java Script Forum