PHP - Post Array Size Limit, But Not Mb
I have a form which has a variable size, depending on the number of rows in a table. For each row there are about ten fields, and I simply show them all for each row.
I've recently started having a trouble in that if I create a form with more than 400 elements, then the $_POST variable is truncated at 400. Is this normal? Do I have to limit the size of the $_POST array? Not by MB, which must be trivial for me, but for the number of array elements? Similar TutorialsUnless buffer overflows or breaking out of code to perform a new command are problems that have been solved.... I am trying to figure out the proper PHP method for setting a boundary on a variable within a script. I have this variable $name which is fed a value from $_POST['name'] from a form field. Now this form field is limited in the HTML to accept only 20 characters, but someone could easily edit the form or outgoing post data. So I want to know how to limit the variable size in the script. In other languages it could be something like this: var name(20). So how do I do that in PHP? Hi Chaps, I'm using readfile to force the download of a file: set_time_limit(0); $file = 'monkey.gif'; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } flush(); And this works fine, however, I do have some software installation files that could be downloaded (these are in excess of 280Mb). I have checked php.ini: Quote memory_limit = 128M post_max_size = 300M But Internet Explorer hangs and then crashes. Is there a way to allow big files to download using this method, or is there another way of forcing the download, without php 'reading' the file first? I'm guessing that the problem lies with the memory_limit being smaller than the file size. Is it a good idea to increase the memory_limit to eg. 280Mb? Cheers Hi, I wanted to realize an upload form for a max. file size of 5GB. Don't ask me why, but my friend needs that. Now I set up a webserver with ISPConfig and this interface provides a lot of features including openbasedir. Uploading files up to 80MB is no problem but choosing bigger files causes the following errors: [Mon Sep 12 23:39:03 2011] [warn] [client XX.XX.XXX.XXX] mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 97477678 bytes) in Unknown on line 0, referer: hxxp://www.mydomain.com/kontakt-upload.html [Mon Sep 12 23:39:03 2011] [error] [client XX.XX.XXX.XXX] Premature end of script headers: file-uploader.php, referer: hxxp://www.mydomain.com/kontakt-upload.html [Mon Sep 12 23:39:03 2011] [warn] [client XX.XX.XXX.XXX] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: hxxp://www.mydomain.com/kontakt-upload.html [Mon Sep 12 23:39:03 2011] [error] [client XX.XX.XXX.XXX] Premature end of script headers: index.php, referer: hxxp://www.mydomain.com/kontakt-upload.html As I see the upload get's buffered in the PHP Memory area instead directly to the harddrive. How could I fix that? I have a simple script which records search terms and writes them to an external file. I would like to limit this file size. The Use: I have a search page where people can search for PDF files. I would like to have a 'cloud tag' or list of the most recent terms searched at the bottom of the page. Here is my script which works beautifully: <?php $pattern = "/filetype:(\w+)/"; // filteype:(wildcard for word) to grab the file extension along with the word filetype: if ( $_GET['q'] == "" ) { $term = ""; } else { $term = preg_replace("$pattern", '', $_GET['q']); // get rid of the filetype parameter } $searched = $term . ", "; $fopen = fopen("searched.html", "a"); fwrite($fopen, $searched); fclose($fopen); ?> The above code grabs the search term when the SERP page is opened, and writes it to a file. I will later use phpInclude to put the contents of that file on the bottom of my search engine page. The problem is that after a million searches, this file will be huge! Question: How can I limit the file size and organize these search terms so that the most recent ones appear on the page? Hi guys, with code below i can upload pictures to database, however i need to limit the file upload. I have this code done with help of php freak forum and i am a newbie so can u help me please? thanks in advance if (isset($_POST['register']) && $_POST['register']){ //image1 $nameone=$_FILES['myfileone']['name']; if ($nameone) { $dst_filename = resize_upload_image($_FILES['myfileone'], "images/"); if ($dst_filename !== false) { extract($dst_filename); $image1 = mysql_query ("INSERT INTO img SET image='$img_filename', thumb='$thumb_filename', refimage='$reference'"); } } } ?> <form action='' method='POST' enctype='multipart/form-data'> <p>File: <input type='file' name='myfileone'> Hi Guys I am using an htmlarea editor and when trying to add more than 1000 characters to this area it gives me an error. The html area editor opens a text file and then posts the changes and rewrites that text file. Any way around this to make it unlimited? I'm trying to add a file size limit to my upload form-code (below) Is there a limit to how many items can be stored in an array? My code looks in a directory of photos and writes the file names into the one-dimensional array. I just switched from my test folder to my actual photo folder - about 600 photos - and when I ran my script with var_dump enabled, my array only goes up to 128 items (0-127). I sure hope arrays aren't that wimpy?! Each photo is about 1-2MB in size, but since I am only storing the file name, I would expect that I could easily store thousands of elements in this array. What is going on?
Hi there, im really stuck here. I have a table of records that are selected from my db and put into an array and randomly chooses them, outputting the results . Code: [Select] <?php $count = 0; while ($row = mysql_fetch_assoc($Ships4)){ $array[$count]['ShipID'] = $row['ShipID']; $array[$count]['ShipName'] = $row['ShipName']; $array[$count]['Dclass'] = $row['Dclass']; $count++; $total4 = count($array); $random4 = rand(0,$total4 - 1); $random_ship4 = $array[$random4]; $ShipID4 = $random_ship4['ShipID']; echo $ShipID4;} This all works fine, however I want to limit the number of random outputs from a number in a record in a different table. So i added: Code: [Select] <?php if ($count < $row_dclasscorella['Dclass4_totla']){ ?> the number from the field is 2. The trouble is that it doesnt take any notice and outputs the total number a random number for each record. It seems its not limiting it. How can i get this to work please??? Code: [Select] $count = 0; if ($count < $row_dclasscorella['Dclass4_totla']){ while ($row = mysql_fetch_assoc($Ships4)){ $array[$count]['ShipID'] = $row['ShipID']; $array[$count]['ShipName'] = $row['ShipName']; $array[$count]['Dclass'] = $row['Dclass']; $count++; $total4 = count($array); $random4 = rand(0,$total4 - 1); $random_ship4 = $array[$random4]; $ShipID4 = $random_ship4['ShipID']; echo $ShipID4;}}?> Thank You $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}';i try this n reslut was :There are no valid items in cart: help me plz Edited by ShivaGupta, 30 November 2014 - 01:11 AM. Ok so I have someone needing me to write a php page(s) to basically check the current size of a file in a directory and display the current size and max allocated size then create a dynamically changing image to reflect those parameters(i.e. pise chart, bar graph, etc.) all called to an intranet page. I work at a business where we upload OS images to a server file but that file is only allocated so much space. The problem we are running into is that we do not know when the space is full until all of our uploads fail. We are attempting to create a visual representation of that space so that we know when to purge the space of the old temporary images. I dont even know where to start on this .. would someone please point me in the direction of some code that would get me started on building this project? I have exhausted my efforts on Google and other PHP pages.. I am new to PHP so I may already be in over my head but I am adventurous and will try anything. Thanx in advance Khaelyx Hey folks! Happy what ever you are celebrating I am trying to limit the number of characters to 200 that this array echos. I have tried a few things... I have tried using "substr($arr_tem, 0, 200)" but obviously it is not working... but I think I am close-ish. Any assistance would be great! Code: [Select] ###print array### echo (implode(", ", array_keys($arr_tem))); Thanks! Hi
How can limit only required input fields cannot be empty.
<form name="test" method="post" action="test.php"> <label for="quest"> <input type="text" name="quest" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> <!-- REQUIRED --> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="answers"> <input type="text" name="answers[]" /> </label> <label for="submit"> <input type="submit" name="submit" value="Submit" /> </label> </form>Following function working only on all empty input fields, i need help to enable button when required fields is not empty. $(document).ready(function() { var $submit = $("input[type=submit]"), $inputs = $('input[name=quest], input[name=answers[]]'); function checkEmpty() { // filter over the empty inputs return $inputs.filter(function() { return !$.trim(this.value); }).length === 0; } $inputs.on('keyup', function() { $submit.prop("disabled", !checkEmpty()); }).keyup(); // trigger an initial blur }); I have these two tables...
schedule (gameid, homeid, awayid, weekno, seasonno)
teams (teamid, location, nickname)
This mysql query below gets me schedule info for ALL 32 teams in an array...
$sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } }However, I only want to get info for one specific team, which is stored in the $teamid variable. This should be very easy, right? I have tried multiple things, including this one below (where I added an AND statement of "AND (h.teamid=$teamid OR a.teamid=$teamid)"), but this one still outputs too much... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014 AND (h.teamid=$teamid OR a.teamid=$teamid)"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } }Below is the array that the above outputs. In a nutshell, all I want is that 1st array ([1]) which has, in this example, the Eagles full schedule. It's not giving me too much else and I guess I could live with it and just ignore the other stuff, but I'd rather be as efficient as possible and only get what I need... Array ( [1] => Array ( [1] => Jaguars [2] => @ Colts [3] => Redskins [4] => @ 49ers [5] => Rams [6] => Giants [7] => BYE [8] => @ Cardinals [9] => @ Texans [10] => Panthers [11] => @ Packers [12] => Titans [13] => @ Cowboys [14] => Seahawks [15] => Cowboys [16] => @ Redskins [17] => @ Giants ) [27] => Array ( [1] => @ Eagles ) [28] => Array ( [2] => Eagles ) [4] => Array ( [3] => @ Eagles [16] => Eagles ) [14] => Array ( [4] => Eagles ) [15] => Array ( [5] => @ Eagles ) [3] => Array ( [6] => @ Eagles [17] => Eagles ) [] => Array ( [7] => @ Eagles ) [16] => Array ( [8] => Eagles ) [25] => Array ( [9] => Eagles ) [11] => Array ( [10] => @ Eagles ) [7] => Array ( [11] => Eagles ) [26] => Array ( [12] => @ Eagles ) [2] => Array ( [13] => Eagles [15] => @ Eagles ) [13] => Array ( [14] => @ Eagles ) ) This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=314962.0 Hi all, Can anyone tell me why the declaration below won't work??? Thnx Ryflex $amount = array(0 => $_POST['$n[0]'], 1 => $_POST['$n[1]'], 2 => $_POST['$n[2]'], 3 => $_POST['$n[3]']); I seem to be having a problem with this code. It's supposed to parse the file info.txt and explode comma separated values into an array and then add each value from that file to the end of a URL and POST that url. What I'm getting now is just the first number in the array. Anyway, here's the code: Code: [Select] <?php $FileName = "info.txt"; $FileHandle = fopen($FileName,"r"); $FileContent = fread ($FileHandle,filesize ($FileName)); fclose($FileHandle); // You can replace the \t with whichever delimiting character you are using $SplitContent = explode("\t", $FileContent); foreach($SplitContent as $CurrValue) { header('Location: http://website.com/file.php?value=' . $CurrValue); } ?> I have a dynamic form that I am writing a script for to allow people to modify the fields of the form. I am taking all of the information that they have entered into the post array. Where I am having a problem is that it is not showing all of the fields in the post array. One of the fields is an image field and the name of the image does not show up in the array when I do print_r or anything. One other thing that I would like to know is how to get rid of the submit key and value from the array. I have tried using the unset method but it still shows up in the array. Code: [Select] <?php session_start(); include ('includes/connection.php'); connect(); $table = $_GET['table']; $id = $_GET['id']; $errors = array(); $mod_sql = "SELECT * FROM $table WHERE id = '$id'"; $mod_sql_result = mysql_query($mod_sql); $info = mysql_fetch_assoc($mod_sql_result); $mod_form = "<form name='insert_table' id='insert_table' action='" . $_SERVER['PHP_SELF'] . "?id=$id&table=$table' method='post' enctype='multipart/form-data'> <fieldset> <legend>table information</legend> <input TYPE='hidden' VALUE='" . $table . "' />"; foreach ($info as $key => $val) { $header = str_replace("_", " ", $key); if ($key == 'id') { $mod_form .= "<p>" . $header . ": <input name='" . $key . "' id='" . $key . "' type='text' value='" . $val . "' readonly='readonly' /></p>"; } else if ($key == 'image') { $mod_form .= "<p>Current image: <img style='vertical-align: text-top;' src='../db_images/ad_images/" . $val . "' /><input type='checkbox' name='delete_image' id='delete_image' value='" . $val . "' />Delete this image?</p> <p>" . $header . ": <input name='" . $key . "' id='" . $key . "' type='file' /></p>"; } else { $mod_form .= "<p>" . $header . ": <input name='" . $key . "' id='" . $key . "' type='text' value='" . $val . "' /></p>"; } } $mod_form .= " <p> <input type='submit' name='submit_mod' id='submit_mod' /> </p> </fieldset> </form> "; echo $mod_form; if (isset($_POST['submit_mod'])) { $table = $_POST['table']; $allowed_ext = array('jpg', 'jpeg', 'png', 'gif'); $file_name = $_FILES['image']['name']; $file_ext = (explode(".", $file_name)); $file_ext = strtolower(end($file_ext)); $file_size = $_FILES['image']['size']; $file_tmp = $_FILES['image']['tmp_name']; if (isset($_POST['delete_image'])) { $delete_image_name = $_POST['delete_image']; unlink('../db_images/ad_images/' . $delete_image_name); } if ($file_name != " ") { $new_image = $file_name; move_uploaded_file($file_tmp, '../db_images/ad_images/' . $file_name); } // This is the section of code that I am having trouble with foreach ($_POST as $key => $value) { if ($key == 'image') { $value = $new_image; } $insert_query = "UPDATE $table SET `$key` = '$value' WHERE id = $id"; $insert_action = mysql_query($insert_query); } echo $insert_query; } if (mysql_error()) { $error = "<strong>MySQL error</strong>:<br />" . mysql_errno() . ": " . mysql_error() . "\n<br>When executing:<br>\n$insert_query\n<br>"; $page = $_SERVER["REQUEST_URI"]; $log = "INSERT INTO db_error (`error_id`, `error_page`,`error_text`,`query`) VALUES ('','$page','" . mysql_real_escape_string($error) . "','" . mysql_real_escape_string($mod_sql) . "')"; $insert_log = mysql_query($log); echo $error; if ($insert_log) { echo "<p>Error has been added to the error log</p><p>The error id number is " . mysql_insert_id() . ""; } else { echo "Error adding to error log<br />" . mysql_errno() . ": " . mysql_error(); } } ?> I'm a total noob trying to figure out how to get this function to work right. I want to echo for each Code: [Select] '<OPTION value="'.$SKUCAPS.$skunum.$size.'">'.$size.'</OPTION>' for each size in the $skus[$type][$skunum]['sizes'] array. and if no size exists echo Code: [Select] '<input value="'.$SKUCAPS.$skunum.'" type=hidden" name="item">' Code: [Select] <?php $BANDNAME="Band Name"; $BANDCAPS="BANDNAME"; $BANDLOWER="bandname"; $SKUCAPS="BND"; $SKULOWER="bnd"; $skus = array( 'shirts' => array( '165' => array( 'name' => 'World Khaos Tour <br> Limited Edition Tour Track Jacket.', 'price' => '70.00', 'sizes' => array('M', 'L', '1X' ) ), '139' => array( 'name' => 'KHAOS LEGIONS ALBUM COVER', 'price' => '15.95', 'sizes' => array('S', 'M', 'L', '1X' ) ), ), //end product type 'misc' => array( '603' => array( 'name' => 'Ring Button', 'price' => '3.00', 'sizes' => array('none') ), '602' => array( 'name' => 'Logo Button', 'price' => '3.00', 'sizes' => array('none') ) ) //end product type ); //end skus function makeProduct($type){ global $skus; foreach ( $skus[$type] as $skunum => $value) { $price = $skus[$type][$skunum]['price']; $name = $skus[$type][$skunum]['name']; echo ' <!-- PRODUCT BEGIN --> <li class="product" > <a href="images/'.$SKULOWER.$skunum.'lg.jpg" rel="lightbox"><img src="product_files/'.$SKULOWER.$skunum.'.png"></a><br> <strong>'.$name.'</strong><br>'.$SKUCAPS.$skunum.'<br>$'.$price.'<br> <form name="'.$SKUCAPS.$skunum.'" method="GET" target="_blank" action="http://www.jsrdirect.com/cgi-bin/Make-a-Store.cgi"> <input type="hidden" name="band" value="'.$BANDCAPS.'"> <input type="hidden" name="back" value="http://www.jsrdirect.com/bands/'.$BANDLOWER.'/index.html"> <strong>Qty:</strong> <input type="text" name="quantity" size="1" value="1" > <strong>Size:</strong> <SELECT name="item">'.makeSizes(). '</SELECT> <br><br> <input class="css3button" value="Add To Cart" type="image"> </form> </li> <!-- Product End -->'; } } ?> any help would be greatly appreciated Hi - I have an HTML form which is dynamically produced using CodeIgniter / PHP and presents products a customer has ordered. When the customer has finished changing his quantities they must now submit the form. My problem is that my form will contain many of the same named fields for example, 'Product ID', or 'Product Name' or 'quantity'. So now when it gets processed a typical post array like product id could look like this: Code: [Select] Array ( [0] => 28 [1] => 24 [2] => 101 [3] => 23 [4] => 17 ) Of course I get an error: Quote Severity: Notice Message: Array to string conversion Filename: mysql/mysql_driver.php I really need some advice on how I should pre-process the various POST arrays so I can get them into my DB. A very grateful student of PHP ! Thanks |