PHP - Get File Error.
I have no idea whats wrong with this. I'm trying to make it so i can collect all the .jpg images in a the $servername's folder to display as a thumbnail set up with javascript and css.
<?php if(!empty($images)) { ?> <div class="highslide-gallery"> <?php $pic_listing = mysql_query("SELECT * FROM toplist WHERE id='". $id ."'") or die(mysql_error()); while($serverpic = mysql_fetch_array($pic_listing)) { // $picture1 = $serverpic["picture1"]; // $picture1info = $serverpic["picture1info"]; $servername = $serverpic["servername"]; } $directory = "images/serverpic/" . $servername . ""; $images = glob("" . $directory . "*.jpg"); foreach($images as $image) { ?> <a href="images/serverpic/<?php echo $servername . "/" . $image; ?>" class="highslide" onclick="return hs.expand(this)"> <img src="images/serverpic/<?php echo $servername . "/" . $image; ?>" alt="Highslide JS" width="100" height="100" title="Click to enlarge" /> </a> <div class="highslide-caption"> <?php } // echo $picture1info; ?> </div> <?php ?> </div> <?php } ?> Similar TutorialsHi guys i have this error, Parse error: syntax error, unexpected end of file in C:\wamp64\www\nigthclub\videos.php on line 103
but i know is probably easy to solve but for some reason i dont see the error. please help me <?php session_start(); ?> <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="tablefiestas.css" rel="stylesheet" type="text/css" /> <title>La Taverna de Juan</title> </head> <body> <div id="container"> <div id="header"> <!--MENU BAR--> <?php include("includes/db.php"); ?> </div> <!--VIDEOS--> <?php $query = ("SELECT * from videos"); $result = mysqli_query($connection,$query); $num_per_page =05; ?> <table border="1" width="100%"> <tr> <td>Video Id</td> <td>Titulo</td> <td>Video</td> </tr> <tr> <?php while ($row=mysqli_fetch_assoc($result)) { $videoid = $row['videoid']; $titulo = $row['titulo']; $url_video = $row['url_video']; ?> <td><?php echo $videoid ?></td> <td><?php echo $titulo ?></td> <td><?php echo $url_video ?></td> </tr> <?php}?> </table> <?php $query = "SELECT * from videos"; $pr_result = mysqli_query($connection,$query); $totalrecord = mysqli_num_rows($pr_result); echo $totalrecord; ?> <br> <div id="footer"> <!--FOOTER--> <?php include("includes/footer.inc.php"); ?> </div> </div> </body> </html> Edited November 18, 2019 by Psycho Added code tags Hi, I got this form, but I dont want the form to be displayed if the user has run out of credits.
The page worked until I added the credit check and now I get this error
Parse error: syntax error, unexpected end of file in /Applications/XAMPP/xamppfiles/htdocs/other_items.php on line 269
I know this is because some } are missing, but whenever I move them about, it either doesnt work, or says there is no { to match the } with. Im really confused now and got another 2 pages to do this to, so really need to sort this one out.
Here is what I got
<?php include 'init.php'; include 'includes/overall/header.php'; include 'includes/logo.php'; if (!isset($_SESSION['loggedin'])) { die("You must be logged in to sell a item"); //this causes to script to stop executing and lets the user know there is a problem /* Note: instead of the die() function, you could use the echo() function and provide an HTML link back to the login page, or use the header() function to just redirect users to the login page without any message. It is up to you to decide what your application should behave. */ } //else { //logged in elseif (isset($_SESSION['loggedin']) ){ //logged in $username = $_SESSION['loggedinuser']; $results = $con->query("SELECT * FROM user WHERE username = '$username';"); while($row = $results->fetch_array()) { $email = $row['email']; $town = $row['town']; $county = $row['county']; } } // THIS IS NEW // CHECK WHETHER USER HAS CREDITS REMAINING $query = "SELECT SUM(amount) FROM transaction WHERE username = $username"; $result = mysqli_query($con, $query); if($result) { $row = mysqli_fetch_row($result); $amount = $row['amount']; if ( ($amount) <= 0) { //not enough credits - show message and redirect echo "You either have no remaining credits or not enough to complete this transaction. You will be redirected to purchase more."; header( "Refresh:5; url=purchase.php", true, 303); exit(); } else { // UP TO HERE ?> <script type="text/javascript" src="jquery.js"></script> <form action="otherItemsCheck.php" id="sellForm" method="POST"> <input type="hidden" name="username" value="<?php echo $username ?>"></li> <input type="hidden" name="email" value="<?php echo $email ?>"></li> <input type="hidden" name="town" value="<?php echo $town ?>"></li> <input type="hidden" name="county" value="<?php echo $county ?>"></li> <h2>Sell your item</h2> <p><strong>A basic listing will cost 1 credit - extras will be added to the total cost of your listing</strong></p> <ul> <li>Category*:</br> <select name="category"> <option value="none">--choose--</option> <option value="air_pumps">Air Pumps</option> <option value="air_stones">Air Stones</option> <option value="aquariums">Aquariums</option> <option value="cleaning">Cleaning & Maintenance</option> <option value="equipment">CO2 Equipment</option> <option value="coral">Coral & Live Rock</option> <option value="decorations">Decorations</option> <option value="feeders">Feeders</option> <option value="filter_media">Filter Media & Accessories</option> <option value="food">Food</option> <option value="gravel">Gravel & Substrate</option> <option value="health_care">Health Care</option> <option value="heaters">Heaters & Chillers </option> <option value="lighting">Lighting & Hoods</option> <option value="meters">Meters & Controllers</option> <option value="deionization">Reverse Osmosis & Deionization </option> <option value="tubing">Tubing & Valves</option> <option value="uv">UV Steriliser Water Pumps</option> <option value="water_tests">Water Tests & Treatment</option> <option value="other">Other Fish & Aquarium</option> </select> </li> <li>Listing Title*:</br> <input type="text" name="listing_title"> <li><strong>Would you like your listing displayed in Bold?: <input type="checkbox" name="bold" value="1"/> 1 Credit</strong> </li> <li>Condition*:</br> <select name="item_condition"> <option>--choose--</option> <option value="New (Packaged)">New (Packaged)</option> <option value="New (None or damaged packaging">New (None or damaged packaging</option> <option value="Used - Working">Used - Working</option> <option value="Used - Not Working">Used - Not Working</option> </select> </li> <li>Brand*:</br> <select name="brand"> <option>Choose...</option> <option value="AI (Aqua Illumination)">AI (Aqua Illumination)</option> <option value="Algarde">Algarde</option> <option value="API">API</option> <option value="AquaEl">AquaEl</option> <option value="AquaGro">AquaGro</option> <option value="Aquamedic">Aquamedic</option> <option value="Aquarian">Aquarian</option> <option value="Aquarium Systems">Aquarium Systems</option> <option value="Aquatlantis">Aquatlantis</option> <option value="Arcadia">Arcadia</option> <option value="Azoo">Azoo</option> <option value="BiOrb/Reef One">BiOrb/Reef One</option> <option value="Blagdon">Blagdon</option> <option value="Boyu">Boyu</option> <option value="Classica">Classica</option> <option value="Cloverleaf">Cloverleaf</option> <option value="Deltec/D-D">Deltec/D-D</option> <option value="Dennerle">Dennerle</option> <option value="Eheim">Eheim</option> <option value="ESHa">ESHa</option> <option value="Hagen/Fluval">Hagen/Fluval</option> <option value="Hikari">Hikari</option> <option value="Hobby">Hobby</option> <option value="Hugo Kamishi">Hugo Kamishi</option> <option value="Interpet">Interpet </option> <option value="JMC">JMC</option> <option value="Juwel">Juwel</option> <option value="King British">King British</option> <option value="New Era">New Era</option> <option value="Nishikoi">Nishikoi</option> <option value="NT Labs">NT Labs</option> <option value="Oase">Oase</option> <option value="Ocean Nutrition">Ocean Nutrition</option> <option value="Penn Plax">Penn Plax</option> <option value="Pontec">Pontec</option> <option value="Red Sea">Red Sea</option> <option value="Rena">Rena</option> <option value="Salifert">Salifert</option> <option value="Seachem">Seachem</option> <option value="Seneye">Seneye</option> <option value="SuperFish">SuperFish</option> <option value="Tanktests">Tanktests</option> <option value="Tetra">Tetra</option> <option value="TMC">TMC</option> <option value="Tunze">Tunze</option> <option value="Two Little Fishies">Two Little Fishies</option> <option value="Waterlife">Waterlife</option> <option value="Wave Point">Wave Point</option> <option value="other">Other</option> </select> </li> <li>Model*:</br> <input type="text" name="model"> </li> <li>Colour*:</br> <select name="colour"> <option value="">--choose one--</option> <option value="White">White</option> <option value="Grey">Grey</option> <option value="Black">Black</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Orange">Orange</option> <option value="Red">Red</option> <option value="Multicoloured">Multicoloured</option> <option value="Other">Other</option> </select> </li> <li>Quantity*:</br> <select name="quantity"> <option value="">--choose one--</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select><strong> 1 Credit entitles you to sell up to 10 of the same item. </strong> </li> <li>Price*:<br> <input type="text" name="price"> In UK Pound Sterling </li> <li>Description*:</br> <textarea name="comments"></textarea> </li> <li>Postage Type*:</br> <select name="postage_type"> <option>Choose...</option> <option disabled>Economy services</option> <option value="UK_CollectPlusTracked">Collect+ Economy Tracked (3 to 5 working days)</option> <option value="UK_HermesTracked">Hermes Tracked (3 to 5 working days)</option> <option value="UK_RoyalMailSecondClassStandard">Royal Mail 2nd Class (2 to 3 working days)</option> <option value="UK_RoyalMailSecondClassRecorded">Royal Mail 2nd Class Signed For (2 to 3 working days)</option> <option value="UK_RoyalMailTracked">Royal Mail Tracked 48 (2 to 3 working days)</option> <option value="UK_RoyalMail48">Royal Mail 48 (2 to 3 working days)</option> <option value="UK_OtherCourier3Days">Other Courier 3 days (3 working days)</option> <option value="UK_OtherCourier5Days">Other Courier 5 days (5 working days)</option> <option value="UK_OtherCourier">Other Courier (3 to 5 working days)</option> <option value="UK_SellersStandardRate">Other Courier 3-5 days (3 to 5 working days)</option> <option disabled>Standard services</option> <option value="UK_RoyalMailFirstClassStandard">Royal Mail 1st Class (1 working day)</option> <option value="UK_RoyalMailFirstClassRecorded">Royal Mail 1st Class Signed For (1 working day)</option> <option value="UK_RoyalMailNextDay">Royal Mail Tracked 24 (1 working day)</option> <option value="UK_RoyalMail24">Royal Mail 24 (1 working day)</option> <option value="UK_CollectPlusStandard">Collect+ Standard (2 working days)</option> <option value="UK_Parcelforce48">Parcelforce 48 (1 to 2 working days)</option> <option value="UK_OtherCourier48">Other 48 Hour Courier (1 to 2 working days)</option> <option disabled>Express services</option> <option value="UK_RoyalMailSpecialDeliveryNextDay">Royal Mail Special Delivery (TM) 1:00 pm (1 working day)</option> <option value="UK_RoyalMailSpecialDelivery9am">Royal Mail Special Delivery (TM) 9:00 am (1 working day)</option> <option value="UK_Parcelforce24">Parcelforce 24 (1 working day)</option> <option value="UK_OtherCourier24">Other 24 Hour Courier (1 working day)</option> <option disabled>Services from outside UK</option> <option value="UK_EconomyShippingFromOutside">Economy Delivery from outside UK (10 to 22 working days)</option> <option value="StandardDeliveryfromOutsideUKwithRoyalMail">Standard Delivery from outside UK with Royal Mail (7 to 13 working days)</option> <option value="UK_StandardShippingFromOutside">Standard Delivery from outside UK (4 to 10 working days)</option> <option value="UK_ExpeditedShippingFromOutside">Express Delivery from outside UK (1 to 3 working days)</option> <option value="UK_FedExIntlEconomy">FedEx International Economy (3 to 4 working days)</option> <option value="UK_TntIntlExp">TNT International Express (2 to 3 working days)</option> <option value="UK_TrackedDeliveryFromAbroad">Tracked delivery from outside UK (2 to 5 working days)</option> <option disabled>Collection</option> <option value="UK_CollectInPerson">Collection in Person </option> </select> </li> <li>Postage Cost*:</br> <input type="text" name="postage_cost"> </li> </ul> <ul> <li>Upload Photo:</br> <input id="text" type="text" name="upload_photo"> </li> <li><input type="checkbox" name="rotate" value="10"/><strong>For 10 credits, you can have your listing displayed on our homepage on a rotation basis. </strong> </li> <li> <input type="submit" value="List Item"></li> </ul> </form> <script type="text/javascript" src="saleSpecies.js"></script> <?php } include 'includes/overall/footer.php'; ?>eg, it says this } he <?php } include 'includes/overall/footer.php'; ?>Is unmatched. I know whats wrong, just not how to fix it Any help is always much appreciated. aquaman Hi i tried to fix something but ended up screwing something up.Ive got a problem and i dont know how to fix it. Down here u can see the code. the error im getting is "Parse error: syntax error, unexpected end of file." Could someone please help me?
Hello, i got a problem with my codes, it says Parse error: syntax error, unexpected token "endwhile" . Please help me, Here's my code:
<?php
while($rows=mysqli_fetch_array($result)); files that upload during insert/submit form was gone , only files upload during the update remain , is the way query for update multiple files is wrong ? $targetDir1= "folder/pda-semakan/ic/"; if(isset($_FILES['ic'])){ $fileName1 = $_FILES['ic']['name']; $targetFilePath1 = $targetDir1 . $fileName1; //$main_tmp2 = $_FILES['ic']['tmp_name']; $move2 =move_uploaded_file($_FILES["ic"]["tmp_name"], $targetFilePath1); } $targetDir2= "folder/pda-semakan/sijil_lahir/"; if(isset($_FILES['sijilkelahiran'])){ $fileName2 = $_FILES['sijilkelahiran']['name']; $targetFilePath2 = $targetDir2 . $fileName2; $move3 =move_uploaded_file($_FILES["sijilkelahiran"]["tmp_name"], $targetFilePath2); } $targetDir3= "folder/pda-semakan/sijil_spm/"; if(isset($_FILES['sijilspm'])){ $fileName3 = $_FILES['sijilspm']['name']; $targetFilePath3 = $targetDir3 . $fileName3; $move4 =move_uploaded_file($_FILES["sijilspm"]["tmp_name"], $targetFilePath3); } $query1=("UPDATE semakan_dokumen set student_id='$noMatrik', email= '$stdEmail', surat_tawaran='$fileName', ic='$fileName1',sijil_lahir='$fileName2',sijil_spm= '$fileName3' where email= '$stdEmail'");
Can anyone help me to fix this two error?
#upload directory path mysqli_select_db($conn, "test2") or die(mysql_error()); Thank you !
Hello, i'm trying to upload a file through a page, on a local wamp server. Here's the code i'm using: Code: [Select] <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Upload" /> </form>This is the form i'm using to pass my file Code: [Select] <?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br />"; if (move_uploaded_file($_FILES["file"]["tmp_name"], $_SERVER['DOCUMENT_ROOT']. "/template_example/slideshow/images/" . $_FILES["file"]["name"])) { echo "Stored in: " . $_SERVER['DOCUMENT_ROOT'] . "localhost/template_example/slideshow/images/" . $_FILES["file"]["name"]; } } ?> The problem comes up if i try to upload an image file of size 1,07 MB. upload_max_filesize on my php.ini is at 2M. I also tried changing it to 2000M just to see if thats the problem. The error code i'm getting is 2 which means: Value: "2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form." from what i got on the internet. My operating system is windows XP SP2 and i have wamp server installed. Please help! I have a script which creates a Thumbnail image if one does not exists, the problem is i keep getting this error: Catchable fatal error: Object of class SimpleImage could not be converted to string in /homepages/22/d378569747/htdocs/scripts/primary_image.php on line 21 i have checked the logs and i think its a read error because the the image is already in use by the server if i remove (!file_exists("$root/thumnail_user_images/$image")) the script work fine, is there anyway to stop this error occuring? <?php //header('Content-Type: image/jpeg'); $root = $_SERVER['DOCUMENT_ROOT']; require("$root/include/mysqldb.php"); //mysql login details require("$root/include/mysql_connect.php"); //mysql connect $uin = $_GET['uin']; $result = mysql_query("SELECT * FROM Reg_Profile_images WHERE UIN='$uin' AND `primary` = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $image = $row[2]; if (!file_exists("$root/thumnail_user_images/$image")) { require("$root/include/image_resizing_function.php"); //create image $image = new SimpleImage(); $image->load("$root/raw_user_images/$image"); $image->resizeToWidth(250); $image->save("$root/thumnail_user_images/$image"); $image->output(); } else { readfile("$root/thumnail_user_images/$image"); } } //End Image file ?> Hi want to upload file using form's input type="file" then i want to display it on another page, As i am new to PHP i am doing this step by step so that I can test each step and go ahead. My first step is to upload file and check if its uploading in temp location.. I got same code from net.. I am using notepad++ thats why not sure abt syntax error, What I did is: <html> <body> <form action="index.php" method="POST" enctype="multipart/form-data"> Image: <input type="file" name="image"> <input type="submit" value="Upload"> </form> <?php mysql_connection("localhost","root","admin") or die(mysql_error()); mysql_select_db("searchdeals") or die(mysql_error()); echo $file = $_FILES['image']['tmp_name']; ?> </body> </html> Hi. I have the following code: <?php $host=""; $username=""; $password=""; $db_name=""; $tbl_name="topic"; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $name=$_POST['name']; $detail=$_POST['details']; $sql="INSERT INTO $tbl_name(topic, detail, datetime)VALUES('$name', '$detail', NOW())"; $result=mysql_query($sql); if($result){ echo("Topic created. "); $sql3="SELECT max(id) FROM $tbl_name"; $result3=mysql_query($sql3); $tbl_name2="top_img"; for($i=1; $i<11; $i++){ $uploaddir = '/imgs/'; $uploadfile = $uploaddir . basename($_FILES['img'.$i]['name']); echo '<pre>'; if (move_uploaded_file($_FILES['img'.$i]['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>"; echo("<br><br><a href='site.html'>HOME</a>"); ?> And the error message: Quote Topic created. PHP Error Message Warning: move_uploaded_file(/imgs/Sunset.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/a7129718/public_html/test/add_topic.php on line 28 PHP Error Message Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php73HyFd' to '/imgs/Sunset.jpg' in /home/a7129718/public_html/test/add_topic.php on line 28 Free Web Hosting Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Possible file upload attack! Here is some more debugging info:Array ( [img1] => Array ( [name] => Sunset.jpg [type] => image/jpeg [tmp_name] => /tmp/php73HyFd [error] => 0 [size] => 71189 ) [img2] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 bla bla bla Any idea what the problem might be? Thanks in advance. Bye. http://bayarearcsociety.com/prototype/index.php When I click the Home link in the nav panel I get these errors Code: [Select] Warning: include(/content/pages/testpage.php) [function.include]: failed to open stream: No such file or directory in /home/bayare27/public_html/prototype/content/maincontent.php on line 7 Warning: include() [function.include]: Failed opening '/content/pages/testpage.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/bayare27/php') in /home/bayare27 /public_html/prototype/content/maincontent.php on line 7 index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" > <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-language" content="en" /> <link type="text/css" rel="stylesheet" href="css/reset.css" /> <link type="text/css" rel="stylesheet" href="css/960.css" /> <link type="text/css" rel="stylesheet" href="css/custom.css" /> <title></title> </head> <body> <div id="wrapper" class="container_12"> <div id="header" class="grid_12"> <div id="left-header" class="grid_5 alpha"></div> <div id="newsflash" class="grid_7 omega"><?php include('content/newsflash.php'); ?></div> </div> <div id="leftmenu" class="grid_3"><?php include('content/menu.php'); ?></div> <div id="maincontent" class="grid_9"><?php include('content/maincontent.php'); ?></div> <div id ="footer" class="grid_12"><?php include('content/footer.php'); ?></div> </div><!-- end wrapper --> </body> </html> menu.php <?php ?> <div class="content"> <ul id="menu"> <li><a href="<?php echo htmlentities($_SERVER['SCRIPT_NAME']); ?>?page=testpage"><span>Home</span></a></li> <!-- Tried both these $_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME']--> <li><a href=""><span>About us</span></a></li> <li><a href=""><span>Schedule</span></a></li> <li><a href=""><span>Media</span></a></li> <li><a href=""><span>Products</span></a></li> <li><a href=""><span>Miscellaneous</span></a></li> </ul> </div> testpage.php <?php ?> <p> lalalaa </p> The file structure on the server is: prototype content - I know these are ok pages - testpage.php is in this file css - I know these are ok images - I know this one is ok Just don't know what to do next. Thanks I apologize, I thought I was posting in php. I assume you will move it. hi, i am trying to code a file uploader in php using IIS server this is the code of the form: <html><body> <form method="post" enctype="multipart/form-data" action="processform.php"> <input type="hidden" name="MAX_FILE_SIZE" value="200000"> <input type="file" name="thefile"><br/> <input type="submit" value="Submit File...."> </form> </body></html> this is the code of processform.php <?php $upload_dir = "C:/Inetpub/wwwroot/cbt/upload/"; $upload_file = $upload_dir . basename($_FILES['thefile']['name']); if(copy($_FILE['thefile']['tmp_name'],$upload_file)){ echo "File copy was Successful!"; } else { echo "Oops... something went wrong..."; print_r($_FILES); } ?> now the problem is each time i try to click on the submit button after browsing any file it shows the message : Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php13.tmp [error] => 0 [size] => 59592 ) ) help me guys...... wats the problem with the code ? Hey, i'd like to extract filenames from my database and present them as a downloadable zip-file to my users. I found a usefull function on http://davidwalsh.name/create-zip-php and thought i could work that out to my needs, but on this function itself (before using it), i get an error.. on the following line: if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { i get: Parse error: syntax error, unexpected ')', expecting '(' i dont get it, dont think there is actually an error in the function.. does it mean that the php installed on the server i use, cant handle this function or anything? my phpinfo: http://dwarsfluit.davidvandiepen.nl/test.php the function is: Code: [Select] <?php /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in... if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; } } } //if we have good files... if(count($valid_files)) { //create the archive $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach($valid_files as $file) { $zip->addFile($file,$file); } //debug //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } }?> thanks for helping! I am working on a video-hosting site, something akin to YouTube. I converted whatever MySQLi I had to PDO. This piece of particular code is responsible for checking if the fields are filled in; then proceeds to upload the files and inserts data into the database. The code jumps straight to the error I created which is "empty fields". The var_dump prints out as null all the way. I cannot seem to figure out where the problem lies. I would say it could be that the file is not set? I am not quite sure. Here is what the log gives me: [Sat Feb 16 00:19:35.575770 2019] [php7:warn] [pid 16239] [client 127.0.0.1:42504] PHP Warning: POST Content-Length of 12263648 bytes exceeds the limit of 8388608 bytes in Unknown on line 0, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576769 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: video_title in /var/www/html/soapbox/upload.php on line 15, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576805 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: textarea-videoDesc in /var/www/html/soapbox/upload.php on line 16, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576811 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: videoFile in /var/www/html/soapbox/upload.php on line 22, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576829 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 51, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576845 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 52, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576849 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 53, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576854 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 54, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576858 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 55, referer: http://localhost/soapbox/upload.php [Sat Feb 16 00:19:35.576862 2019] [php7:notice] [pid 16239] [client 127.0.0.1:42504] PHP Notice: Undefined index: thumbnailImage in /var/www/html/soapbox/upload.php on line 56, referer: http://localhost/soapbox/upload.php I have changed the allotted sizes in the php.ini file, so that rules out the POST Content-Length problem, I think. Here are the "undefined indexes": $videoTitle = $_POST['video_title']; $videoDesc = $_POST['textarea-videoDesc']; $file = $_FILES['videoFile']; $thumbnailImageName = $_FILES['thumbnailImage']['name']; $thumbnailImageTmpName = $_FILES['thumbnailImage']['tmp_name']; $thumbnailImageSize = $_FILES['thumbnailImage']['size']; $thumbnailImageError = $_FILES['thumbnailImage']['error']; $thumbnailImageType = $_FILES['thumbnailImage']['type']; $thumbnailImageExt = explode('.', $thumbnailImageName); And the corresponding form names to go with them: <form action="upload.php" method="POST" enctype="multipart/form-data" multiple><br> <p>Video File:</p><input type="file" name="videoFile" id="fileToUpload"><br> <p>Thumbnail Image File: </p><input type="file" name="thumbnailImage"><br> <p>Video Title: </p><input type="text" name="video_title" id="videoTitle" placeholder="Video title"><br> <p>Video Description</p><textarea name="textarea-videoDesc" placeholder="Video description..." rows="7" style="resize: none;"></textarea><br> <br><input type="submit" name="uploadBtn" value="Upload"> </form>
Say I have... Code: [Select] <? echo("do something"); include("include_file.php"); echo("do something else"); ?> include_file.php Code: [Select] <? $a_$string = "a string"; echo($a_string); ?> I have put an error in the include_file.php an extra $ in the variable name. The first script would kick up an error that there is a problem with file include_file.php as line 3 or what ever the line may be. How can I have it so I can choose what the error message is, say a cryptic code and the line number without having the file names show as this is showing up my hidden includes folder and the file name which means that someone may try to visit this page alone and this can cause security issues. Adding in extra lines to every file to see if it is being use correctly a bit like sessions is not an option although I have looked at it as I have houndreds of files to alter in this case. I have just tried this instead of the top script but I does not show the secret code on error Code: [Select] <? echo("top"); @include("dummy.php") or die("secreterrorcode123"); echo("bottom"); ?> Need some help with this script. I'm looking to limit the type of file you can upload to my server the script uploads ok but i when i try t view the uploaded file but i get an error cant find file extension for this file what am i doing wrong as i'm very new to php . Thank for your help in advance Code: [Select] <?php $allowedExtensions = array("jpg","jpeg","gif","png","bmp"); foreach ($_FILES as $image) { if ($image['tmp_name'] > '') { if (!in_array(end(explode(".", strtolower($image['name']))), $allowedExtensions)) { die($image['name'].' is an invalid file type!<br/>'. '<a href="javascript:history.go(-1);">'. '<< Go Back</a>'); } } } $target = "testimages/"; $target = $target . basename( $_FILES['image']['name']); // $company=$_POST['company']; $image=($_FILES['image']['name']); mysql_connect("localhost", "user", "pass") or die(mysql_error()) ; mysql_select_db("testupload") or die(mysql_error()) ; mysql_query("INSERT INTO `table` (company, image) VALUES ('$company', '$image')") ; if(move_uploaded_file($_FILES['image']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { echo "Sorry, there was a problem uploading your file."; } ?> Hi Guys, What I am doing is making a backup of a folder by zipping it on a server which is outside of web root, downloading a local copy to a web accessible place and then uploading the zip file back to the non web folder. I am using phpseclib's sftp to achieve this. The error I have is that when the file is uploaded to the non web area, the file is 0 bytes and cannot be used, the copy stored on the web accesible area is fine? The code I am using: Code: [Select] <?php if(isset($_GET['backup'])) { $worldname = $_GET['backup']; //checks to see if upload if(!is_dir("backups")) //create backup directory if not exist { mkdir("backups", 0777); } mkdir("backups/".$worldname, 0777); //make filename directory $main_dest = "backups/".$worldname.""; //set backup destination $delpath = "backups/"; //path which will be deleted later $sftp = new Net_SFTP($host); $sftp->login($root_user, $root_pass); //login to sftp $get = "/root/minecraft/".$worldname."/"; //get correct directory for backup get_folder($sftp, $get, $main_dest ); //execute command Zip('backups/'.$worldname.'','backups/'.$worldname.''.date("dmy-H:i").'.zip'); //make zip of folder $sftp->put('/root/minecraft/backups/'.$worldname.''.date("dmy-H:i").'.zip','backups/'.$worldname.' '.date("dmy-H:i").'.zip',NET_SFTP_LOCAL_FILE); //put zip file from web folder to root/backup folder rrmdir($delpath); //delete old folder (function below) //unlink('backups/'.$worldname.''.date("dmy-H:i").'.zip'); deletes web copy header('Location: index.php'); } The line which is causing the issue is: Quote $sftp->put('/root/minecraft/backups/'.$worldname.''.date("dmy-H:i").'.zip','backups/'.$worldname.' '.date("dmy-H:i").'.zip',NET_SFTP_LOCAL_FILE); The function is basically $remotefile, $data, $mode Can anyone take a guess at what is causing the issue? PHP max upload size is 200mb, the files are around 5mb, the timeout is 360 seconds? Cheers Dave[/code] function GetStatus(){ $fd=read_file('s_status.sta'); list($perf, $msg, $rest) = explode('\n', $fd, 3); if(isset($perf) && isset($msg)){ return '<p class="status"><img src="/images/sta/'.$perf.'.png" /> $msg</p>'; } else { return ''; } } Hi everyone, Thanks for reading. I'm having a problem with my script, I would love to know why it's just stopping parsing and no errors are getting diplayed when I call this function. I'm using E_ALL, Highly annoying when still no errors come up... When the function is called the page stops parseing, The function returns nothing. The files content does like this: Code: [Select] ERROR This is an error Som other stuff I don't need hence $rest in the explode As you can tell it's a status file I checked the contents and it's all in the right format. Thanks in advance! I use this code: Code: [Select] <?php $databasehost = "localhost"; $databasename = "export_ajur"; $databasetable = "invoice"; $databaseusername ="root"; $databasepassword = "password"; $fieldseparator = ","; $lineseparator = "\n"; $csvfile = "1.csv"; $addauto = 0; $save = 1; $outputfile = "output.sql"; if(!file_exists($csvfile)) { echo "File not found. Make sure you specified the correct path.\n"; exit; } $file = fopen($csvfile,"r"); if(!$file) { echo "Error opening data file.\n"; exit; } $size = filesize($csvfile); if(!$size) { echo "File is empty.\n"; exit; } $csvcontent = fread($file,$size); fclose($file); $con = @mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error()); @mysql_select_db($databasename) or die(mysql_error()); $lines = 0; $queries = ""; $linearray = array(); foreach(explode($lineseparator,$csvcontent) as $line) { $lines++; $line = trim($line," \t"); $line = str_replace("\r","",$line); $linearray = explode($fieldseparator,$line); $linemysql = implode("','",$linearray); if($addauto) $query = "insert into $databasetable values('$linemysql');"; else $query = "insert into $databasetable values ('$linemysql');"; $queries .= $query . "\n"; @mysql_query($query); } @mysql_close($con); if($save) { if(!is_writable($outputfile)) { echo "File is not writable, check permissions.\n"; } else { $file2 = fopen($outputfile,"w"); if(!$file2) { echo "Error writing to the output file.\n"; } else { fwrite($file2,$queries); fclose($file2); } } } echo "Found a total of $lines records in this csv file.\n"; ?> And th output is: Code: [Select] insert into invoice values ('ID_PURCHASE_INVOICE','DOC_TYPE_NAME','DOC_EXT_CODE','DOC_NUM','DOC_DATE','WOVAT_AMOUNT','VAT_AMOUNT','TOTAL_AMOUNT','CONTRAGENT_NAME','CONTRAGENT_BULSTAT','CONTRAGENT_VATNUMBER','CONTRAGENT_POST_ADDRESS','CONTRAGENT_ZIP','CONTRAGENT_CITY','CONTRAGENT_AREA','CONTRAGENT_STREET','CONTRAGENT_MOL','CONTRAGENT_PHONE','CONTRAGENT_BANK','CONTRAGENT_BANK_CODE','CONTRAGENT_BANK_ACCOUNT','CONTRAGENT_EXT_CODE','CONTRAGENT_EMAIL','PAYMENT_NAME','DOC_MARKER1','DOC_MARKER2','DOC_MARKER3','DOC_MARKER4','DOC_MARKER5','DOC_MARKER6','DOC_MARKER7','DOC_MARKER8','DOC_MARKER9','DOC_MARKER10'); insert into invoice values ('108826','ДАНЪЧНА ФАКТУРА','1','111366','2/15/2012','160.08','32.02','192.1','ПРЕЦИЗ ООД','103565237','BG103565237','ВАРНА ГЕН.КОЛЕВ 38','','','','','','','','','','','','БАНКА','','','','','','','','','',''); insert into invoice values ('108830','ДАНЪЧНА ФАКТУРА','1','1002304974','2/15/2012','872.33','174.46','1046.79','ОМВ БЪЛГАРИЯ ООД','121759222','BG121759222','','','СОФИЯ','','','','','','','','','','БАНКА','','','','','','','','','',''); insert into invoice values (''); I need to remove last line ' insert into invoice values (''); . How to change my code? Hi Hope someone can help me please. I have constructed an audio dictionary and have discovered an error now that I have added a few entries to the database. A user can search the database and can click on a result to be taken to the content associated with the entry he chooses. This is the search function; Code: [Select] $search=$_POST["search"]; //get the mysql and store them in $result $result = mysql_query("SELECT word FROM pro_words WHERE word LIKE '%$search%'"); //get the db content that is specified above if (mysql_num_rows($result) < 1) { echo "<br><br><h2> We didn't find anything. Sorry - we did look though.</h2>"; }else { echo '<table align="center" cellspacing="8" cellpadding="8" width="85%"><tr><td align="left"><b>Word</b></td></tr>'; echo "<br><br><h2>Success! Here's what we found:</h2><br>"; while ($r=mysql_fetch_array($result, MYSQLI_ASSOC)) echo '<h2><tr><td align="left"><a href="word.php?w=' . $r['word'] . '">' . $r['word'] . '</a></td></tr></h2>'; } You will see that content is displayed in a new file called word.php. This is relevant code from word.php Code: [Select] $query = "SELECT word,word_type1,sentence1,word_type2,sentence2,word_type3,sentence3 FROM pro_words"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo '<div class="colmask rightmenu">'; echo '<div class="colleft">'; echo '<div class="col1">'; echo '<p>Here are some example sentences that show how we use the word; </p>'; echo '<div id="small"><i> ' . $row['word_type1'] . '</i></div>'; echo '<p><div id="small">' . $row['sentence1'] . '</p></div>'; echo '<div id="small"><i> ' . $row['word_type2'] . '</i></div>'; echo '<p><div id="small">' . $row['sentence2'] . '</p></div>'; echo '<div id="small"><i> ' . $row['word_type3'] . '</i></div>'; echo '<p><div id="small">' . $row['sentence3'] . '</p></div>'; } The problem is that every entry on the database is echoed in word.php whereas I would like only the entries for the word selected to appear. Thanks in advance for any help; do say if you need more info. |