For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > February 2005 > Re: [PHP-WIN] form not parsing php code?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-WIN] form not parsing php code?
Randy Clamons

2005-02-10, 3:56 pm

Patrick,

Apparently this is only part of your php code. I see an 'else' but not an =
'if'.

I also note you are sending two form tags. Most browsers will consider the =
second form tag as ending the first form. Include the method attribute with=
the first form tag, and delete the second tag. This should allow your user=
s to upload a file.

Randy Clamons
Systems Programming
Novaspace.com


> ------------Original Message------------
> From: Patrick Roane <fojomo@sbcglobal.net>
> To: php-windows@lists.php.net
> Date: Thu, Feb-10-2005 12:12 PM
> Subject: [PHP-WIN] form not parsing php code?
>
> 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=3D"multipart/form-data"
> name=3D"frmUploadFile" action=3D"<?PHP echo $me;?>"> =


> =


> =


> <?php
> =


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


> =


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


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


> </a>
> =


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


> <tr>
> =


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


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


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


> </tr>
> =


> <tr>
> =


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


> <p style=3D"margin-left: 10; margin-right: 10"><font
> face=3D"Verdana" size=3D"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 "Upload
> this file" button below. 
> =


>  <br> </font></td>
> =


> </tr>
> =


> <tr>
> =


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


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


> File Description:</font></td>
> =


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


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


> </tr>
> =


> <tr>
> =


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


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


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


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


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


> </tr>
> =


> <tr>
> =


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


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


> <br>
> =


> <br>
> =


>  </font></td>
> =


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


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


> <input type=3D"submit" value=3D"Upload this file"
> name=3D"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 =3D=3D "none")
> =


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


> // Database connection variables
> =


> $dbServer =3D "localhost";
> =


> $dbDatabase =3D "myfiles";
> =


> $dbUser =3D "";
> =


> $dbPass =3D "";
> =


> $fileHandle =3D fopen($fileUpload, "r");
> =


> $fileContent =3D fread($fileHandle, $fileUpload_size);
> =


> $fileContent =3D addslashes($fileContent);
> =


> $sConn =3D mysql_connect($dbServer, $dbUser, $dbPass)
> =


> or die("Couldn't connect to database server"); =


> =


> $dConn =3D mysql_select_db($dbDatabase, $sConn)
> =


> or die("Couldn't connect to database $dbDatabase");
> =


> $dbQuery =3D "INSERT INTO myBlobs VALUES ";
> =


> $dbQuery .=3D "(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=3D'uploadfile.php'>Add Another File</a>";
> =


> //}
> =


> ?>
> </body>
> =


> </html>
> =


> =3D=3D=3D=3D=3D
> 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
> =


> =

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com