form not parsing php code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't think my form is parsing the php code. Though,
I'm not getting any errors, I should see a detailed
message confirming the file i've uploaded and I should
see my sql table updated with this information. If
anything, I should see mysql errors if there is a
connection problem. Niether of these things is
happening.


There is obviously a communication problem between the
html and the php. Can someone take a look here to see
if there is something missing? 

<!DOCTYPE html PUBLIC
	"-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html>
<head>
<title>Listing 13.1 Opening a Connection to a
Database</title>
</head>
<body>
<form enctype="multipart/form-data"
name="frmUploadFile" action="<?PHP echo $me;?>"> 
 

<?php
   
print "<form method='post'
action='{$_SERVER['PHP_SELF']}'>";
 ?>


<a href="http://www.devarticles.com";>

<img border="0"
src="http://www.devarticles.com/dlogo.gif";>

</a>

<table border="0" cellpadding="0" cellspacing="0"
bordercolor="#111111" width="100%">

<tr>

<td width="100%" bgcolor="#FF9900" height="22"
colspan="2">

<p style="margin-left: 10"><b><font face="Verdana"
size="2" color="#FFFFFF">

Upload a File</font></b></td>

</tr>

<tr>

<td width="100%" bgcolor="#FFE3BB" colspan="2">

<p style="margin-left: 10; margin-right: 10"><font
face="Verdana" size="2">

<br>Please select a file from your local computer to
upload to our web server

for saving in our database. This file can be of any
type you like. Once you

have chosen a file, please click on the &quot;Upload
this file&quot; button below.&nbsp;

&nbsp;<br>&nbsp;</font></td>

</tr>

<tr>

<td width="15%" bgcolor="#FFE3BB">

<p style="margin-left: 10"><font face="Verdana"
size="2">

File Description:</font></td>

<td width="85%" bgcolor="#FFE3BB">

<input type="text" name="strDesc" size="20"
maxlength="50"></td>

</tr>

<tr>

<td width="15%" bgcolor="#FFE3BB">

<p style="margin-left: 10"><font face="Verdana"
size="2">File Location:</font></td>

<td width="85%" bgcolor="#FFE3BB">

<font face="Verdana" size="2">

<input type="file" name="fileUpload"
size="20"></font></td>

</tr>

<tr>

<td width="33%" bgcolor="#FFE3BB">

<p style="margin-left: 10"><font face="Verdana"
size="2">

<br>

<br>

&nbsp;</font></td>

<td width="67%" bgcolor="#FFE3BB">

<font face="Verdana" size="2">

<input type="submit" value="Upload this file"
name="cmdSubmit"></font></td>

</tr>

</table>

</form>

<?php
//} else {
// GrabFile.php: Takes the details

// of the new file posted as part

// of the form and adds it to the

// myBlobs table of our myFiles DB.



global $strDesc;

global $fileUpload;

global $fileUpload_name;

global $fileUpload_size;

global $fileUpload_type;

// Make sure both a description and

// file have been entered

if(empty($strDesc) || $fileUpload == "none")

die("You must enter both a description and file");

// Database connection variables

$dbServer = "localhost";

$dbDatabase = "myfiles";

$dbUser = "";

$dbPass = "";

$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");

echo "<h1>File Uploaded</h1>";

echo "The details of the uploaded file are shown
below:<br><br>";

echo "<b>File name:</b> $fileUpload_name <br>";

echo "<b>File type:</b> $fileUpload_type <br>";

echo "<b>File size:</b> $fileUpload_size <br>";

echo "<b>Uploaded to:</b> $fileUpload <br><br>";

echo "<a href='uploadfile.php'>Add Another File</a>";

//}

?>
</body>

</html>

=====
Patrick Roane
Web design and development
www.franklin-band.com
Fox River Grove, Il.

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux