Jump to content


Photo

Whats wrong with this script


  • Please log in to reply
9 replies to this topic

#1 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 17 March 2006 - 02:44 AM

ok i go to preview it on the dreamweaver thing and some of this script shows up i cant figure out whats wrong

<?PHP
if($_POST['submit']){
$directory = "/home/username/public_html/files/";
$max_file_size = "26214400";
$allowedfile[] = "video/x-ms-wmv";  
$allowedfile[] = "video/x-msvideo";  
$allowedfile[] = "video/mpeg";  
$allowedfile[] = "video/quicktime";  
if (is_uploaded_file($_FILES["file"]["tmp_name"])) {    
    if($_FILES["file"]["size"]>$max_file_size) {        
        $is_uploaded = "failed";      
        echo 'Sorry, this file is too large. The maximum filesize is '.$max_file_size.' bytes, although your file is '.$_FILES["file"]["size"].'. ';        
        exit();    
        }    
        if(!in_array($_FILES["file"]["type"],$allowedfile)) {        
            $is_uploaded = "failed";        
            echo 'Sorry, wrong file type, "'.$_FILES["file"]["type"].'" is not allowed. ';      
            exit();  
        }    
        if(file_exists($directory.$_FILES["file"]["name"])) {        
            $is_uploaded = "failed";        
            echo 'Sorry, this file already exists. ';        
            exit();
        if($is_uploaded!="failed") {
               $replace = array("$","%","#","@","!","&","^","*","(",")","-");
            $new = str_replace($replace,"",$_FILES["file"]["name"]);
            $fileName = str_replace(" " , "_" , $new);

        if(! is_dir($directory)){
                mkdir($directory,0777);
            }
        if (move_uploaded_file($_FILES["file"]["tmp_name"], $directory.$fileName)) {
                echo "Your file, ". $fileName ." has successfully been uploaded!  Click <a href=\"".$directory.$fileName."\">Here</a> to view your file.";
            }
    else {
        echo 'Sorry, your file has not uploaded.';
        exit();
        }
    }
} else {
    echo 'There has been an unknown error while uploading';
    exit();
}
}
?>


#2 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 17 March 2006 - 04:23 AM

if you do not preview it throught a web browser by typeing [a href=\"http://127.0.0.1\" target=\"_blank\"]http://127.0.0.1[/a] or your ip address or webpage name you will see the code because php only parses it through a web browser
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#3 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 17 March 2006 - 05:57 AM

Actually it has nothing to do with the browser, but PHP is only processed with an interpreter. Dreamweaver does not have an interpreter. You can configure your local system to execute php scripts via the php interpreter or via a httpd, which employs the php interpreter to process the script before passing it to the client that generated the request (generally a web browser).

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.


#4 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 March 2006 - 01:54 AM

ok so what do i do then to fix it

#5 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 March 2006 - 09:05 PM

*bump*

#6 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 March 2006 - 06:45 PM

Down load [a href=\"http://www.apachefriends.org/en/xampp-windows.html\" target=\"_blank\"]xampp[/a] which installes Apache 2, PHP 5, Mysql, perl, python... on your PC. Then you can test your PHP scripts locally.

Ken

#7 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 20 March 2006 - 07:19 PM

ok i got it now i dont understand what to do i go to dreamweaver and it still shows up bad and i dont understnad whats wrong wit it

i alos cant get apache to start only thing running is mysql is that the problem

ok i now uninstalled and then reinstalled and now i have FileZilla running but when i hir start on Apache itll strat for a quick second then itll end

#8 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 21 March 2006 - 06:59 AM

The million dollar question is what is the conflict in your configuration which causes Apache to fail to load. Are there any error messages returned when you try to start Apache?

Dreamweaver will not view PHP files correctly because it does not contain an interpreter and therefore can not comprehend it or the desired end results of it. I don't think I can make it any clearer, at the moment. If anyone feels the need to elaborate, please do so.

Edit: Dreamweaver was only designed to edit (x)html/javascript/dhtml/etc...things that a web browser processes as this deals with the end result. It was not designed to handle things that are processed on the server-side.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.


#9 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 22 March 2006 - 04:16 AM

is there a plugin for a n interpreter in dreamweaver

#10 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 22 March 2006 - 04:21 AM

Though that would be a wonderful tool for those that do not understand (x)html, but would like to make minor changes to their premade scripts, I have no knowledge of such a thing. My suggestion to you is to spend a little time studying xhtml, php and css. Then, if you insist on using a WYSIWYG editor, you will be able to design the page in the editor and go to code view and insert php snippets. It won't look right in the editor, but then you can view it on the server.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users