Jump to content

rich_web_development

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by rich_web_development

  1. I just checked on http://phpcodechecker.com/ It gives the same error I'm getting for the upload.php code I copied from the w3schools website http://www.w3schools.com/php/php_file_upload.asp It gives the same error: Parse error: syntax error, unexpected '$check' (T_VARIABLE) in C:\xampp\htdocs\upload.php on line 8 ​It also gives the same Parse error for the code I copied from the PHP.net website
  2. Changed double quotes to single quotes and still get the same error:
  3. if I change upload.php to: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?> I get an error: Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\upload.php on line 9
  4. I've looked in the apache error logs and keep getting the following: [Fri Sep 02 18:30:30.650622 2016] [ssl:warn] : www.example.com:443:0 server certificate does NOT include an ID which matches the server name [Fri Sep 02 18:30:30.688379 2016] [mpm_winnt:notice]: Child: Starting 150 worker threads. [Fri Sep 02 18:30:58.097000 2016] [:error] [pid:tid ] [client ::] PHP Parse error: syntax error, unexpected '$check' (T_VARIABLE) in C:\\xampp\\htdocs\\upload.php on line 8, referer: http://localhost/PicTest.html I run the XAMPP control panel with admin rights and have clicked on the red x's. It's so annoying. It used to just work but now it just wont let me do what I want. It works with just basic examples from the w3schools PHP tutorial like: <?php $txt1 = "Learn PHP"; $txt2 = "W3Schools.com"; $x = 5; $y = 4; echo "<h2>$txt1</h2>"; echo "Study PHP at $txt2<br>"; echo $x + $y; ?>
  5. I use sublime text 3. I've tried it with notepad and saving as UTF-8 encoded but still get the same Parse errors
  6. <!DOCTYPE html> <html> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> </body> </html> Then for the upload.php: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?> I have a folder called uploads in the same place as the above files in xampp|htdocs. I've even tried a simple example from the php.net website which is as follows: <!DOCTYPE html> <html> <body> <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload1.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="500000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> </body> </html> <?php// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = "uploads";$uploadfile = $uploaddir . basename($_FILES['userfile']['name']); echo '<pre>';if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Possible file upload attack!\n"; } echo 'Here is some more debugging info:';print_r($_FILES); print "</pre>";?> The above gives me an error of : Parse error: syntax error, unexpected '"uploads"' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\upload1.php on line 8 I've used all the above examples in the past with no problems but now it just keeps throwing Parse errors.
  7. I have followed the PHP File Upload instructions at http://www.w3schools.com/php/php_file_upload.asp When I go to up load the photo I get: Parse error: syntax error, unexpected '$check' (T_VARIABLE) in C:\xampp\htdocs\upload.php on line 8 AGAIN! Just to confirm. I have done a copy and paste of what's on the w3schools website for PHP File Upload, I have a fresh install of xampp on my windows 10 machine, I have checked the PHP.ini to make sure file_uploads is set to ON, I have created a UPLOADS folder in the same place as my html file and upload.php. Can someone please help.
  8. Ok. How stupid of me. That was simple. Think I've fixed it now. Changed the CSS to: @media screen and (max-width: 680px){ul.topnav.responsive{position: fixed;right:0px;width:100%;top:0px;} Thank you very much for your help!
  9. Thanks for the reply. The jQuery adds the new class 'fixednav' when on scroll which works fine until the screen goes below 680px. I have the css set so that the navigation bar changes to just display 'menu' and then toggles when clicked to display the navigation options(I used the code that's on the RWD bit of w3schools css). When the screen is below 680px the navigation bar shows only the menu and when you click menu it shows the navigation options. When you click on the menu the navigation bar no longer stick to the top. If you open the f12 tools you can see the .fixednav gets overwritten by the css 'ul.topnav.responsive' which gives it a position of relative. I want the navigation bar to stay stuck to the top even when the menu is clicked.
  10. Hi, I was wondering if anyone could help me. I have managed to get the navigation bar under my header to collapse into a menu when the screen size gets smaller than 680px. I watched a YouTube video on how to get the navigation bar to stick to the top of the screen on scroll. The problem is when the screen is smaller than 680px the navigation bar sticks to the top UNTILL the menu toggles to show the navigation options then the navigation no longer sticks to the top. The jQuery looks like this: jQuery(document).ready(function(){ var navOffset = jQuery(".topnav").offset().top; jQuery(".topnav").wrap('<div class="nav-placeholder"></div>'); jQuery(".nav-placeholder").height(jQuery(".topnav").outerHeight()); jQuery(window).scroll(function(){ var scrollPos = jQuery(window).scrollTop(); if(scrollPos>=navOffset){ jQuery(".topnav").addClass("navfixed"); }else{ jQuery(".topnav").removeClass("navfixed"); } }); }); I've included the css and html I'm using. If someone could please tell me how to get the navigation bar to stick to the top even when the menu is clicked. Thanks testFIX.css testFIX.html
×
×
  • Create New...