-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
What page just refreshes? We need to know exactly what occurs in front of you in order to help. For all we know there's something you are doing in your form that is causing the problem or that your header() statement in the code you posted is redirecting to the page in question or that you have opened the form directly in your browser through the file system and not through a URL on your web server. Edit: I just noticed that you changed the name of the uploaded file field from 'imagefile' to 'file'. Are you sure that is correct?
-
After participating in a few of your recent array based threads and having just reviewed the rest of them, I'm thinking that if you actually show the source of this data and what result you are trying to achieve, that someone can probably give you a general solution that will work. You seem to be throwing a lot of code at a pieces of problem, when a simpler overall solution is probably available, but that would require knowing enough about what you are actually trying to achieve in order to help. We regularly find ways of consolidating multiple-hundred lines of complicated code into just a few lines, once the overall problem has been reveled.
-
Why do you even need to explode the data? It appears that you want to display the entire description. You should likely look at using nl2br when you output the description to give you html <br> tags.
-
$query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', activities = '$activities', hobbies = '$hobbies' WHERE userName = '" .$_SESSION['Email']."'"; or more simply (less error prone, less typing) - $query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', activities = '$activities', hobbies = '$hobbies' WHERE userName = '{$_SESSION['Email']}'"; Are you sure your userName column contains email addresses?
-
Your latest error(s) indicate that the upload failed (probably because the file was too large or you didn't select a file.) See this link for possible upload errors - http://us3.php.net/manual/en/features.file-upload.errors.php At a minimum, your code needs to check that $_FILES isset (exceeding the post_max_size setting will cause the $_FILES array and the $_POST array to be empty and errors in your form or uploads not enabled on the server will also cause the $_FILES array to be empty) and that $_FILES['imagefile']['error'] is equal to zero before you attempt to use any of the the uploaded file information in your logic. if(isset($_FILES) && $_FILES['imagefile']['error']==UPLOAD_ERR_OK){ // the upload worked, use the uploaded file information here... } else { // the upload failed due to an error, handle that condition here - output a user message indicating why the upload failed (some of them the user can correct by uploading a smaller file.) } Also, in the case of an upload form, since the $_POST array can be empty for one of the possible error conditions, you should test if the form has been submitted by using - if($_SERVER['REQUEST_METHOD']=='POST'){
-
how to update infinite amount of rows in 1 query?
PFMaBiSmAd replied to Monkuar's topic in PHP Coding Help
AFAIK to do it in one query, you would need to dynamically produce the query statement using CASE logic (untested) - UPDATE your_table SET rank = CASE WHEN friend = 'shiskabob' THEN 2 WHEN friend = 'test2' THEN 0 WHEN friend = 'monkey' THEN 0 END WHERE id = x -
You are the only one here who can troubleshoot what your code is doing on your server. Did you try any of the troubleshooting tips -
-
The second parameter must be an GD image resource. Here is a link to the imagecopyresampled documentation.
-
In all browsers, $_POST['login_x'] and $_POST['login_y'] will be set if you actually clicked on the image to submit the form. If you used the enter key, some browsers won't set those. Only browsers that are doing their own thing outside of the w3.org specification will set $_POST['login'] for a type='image' submit button. To simply test if a form was submitted, either use a hidden field and test if the hidden field name is set or test if($_SERVER['REQUEST_METHOD'] == 'POST') Use the following code, immediately after your first opening <?php tag, to display exactly what your form is submitting - echo '<pre>',print_r($_POST,true),'</pre>';
-
The @ error suppressor you have in your code is hiding errors that would help pin point what is wrong. Remove the @ in front of the GetImageSize statement.
-
You paginate an array the same way that you would paginate rows from a database, except the values in the LIMIT clause would produce the starting and ending array index values. Assuming that you started with the phpfreaks pagination tutorial (http://www.phpfreaks.com/tutorial/basic-pagination), you would do the following - <?php $arr = array_merge($array1,$array2,$array3); // your combined array // find out how many rows are in the array $numrows = count($arr); <?php // the code that gets the specific rows of data and loops over them - $end = $offset + $rowsperpage; // index wise, this is actually one past the end, to avoid extra -1's in the code. the loop stops at one less than this value. if($end > $numrows){$end = $numrows;} // limit value to prevent undefined index errors (a db doesn't care if the LIMIT is past the end of the data, but an array does) // while there are rows to be fetched... for($i = $offset; $i < $end; $i++) { // echo data echo "$i : {$arr[$i]}<br />"; } // end loop
-
Server/PHP config so you don't have to use $_POST['var']
PFMaBiSmAd replied to Zephni's topic in PHP Coding Help
As long as you use one of the extract flags that prevent overwriting of existing program variables, otherwise you have just opened the door for a hacker to inject his values into your program variables. -
Need solution to my god awful urls for page links.
PFMaBiSmAd replied to floridaflatlander's topic in PHP Coding Help
See the use of http_build_query in this post- http://www.phpfreaks.com/forums/index.php?topic=349554.msg1649534#msg1649534 -
Also, don't use $_REQUEST. It combines post, get, cookie variables and at some point in time, it will burn you while trying to get an expected value. Use the correct $_POST or $_GET variable that you expect the data to be in.
-
You likely have a php.ini configuration difference between your development system and the live server or a problem with the session configuration on the live server. Do you have php's error_reporting set to E_ALL and display_errors set to ON (temporarily) on the live server so that any php detected errors will be reported and displayed to help point out problems that are occurring? Have sessions ever worked on the live server or not just for the the code you are trying now?
-
It means that php.net created a lot of confusion in its early days that has since been turned off by default and will shortly be completely removed from the language. The only things you need to know concerning session variables are - 1) You need a session_start() statement (before you send any characters/html to the browser) on any page that sets or references a session variable. 2) You set or reference session variables by setting or referencing the $_SESSION super-global array.
-
^^^ The above statement in your code is fetching and discarding the first row from the result set. Why do you have that line in your code?
-
<?php $string =" Status Changed to In Progress\. -- Tuesday 15th September 2009 04:12:40 PM by Operator--//-- Status Changed to Closed\. -- Friday 18th September 2009 10:39:41 AM by Admin--//-- "; $parts = explode('--//--',$string); // call back function for array_filter function find_closed($string){ $find = "Status Changed to Closed"; $pos = strpos($string, $find); return ($pos === false) ? false : true ; } $result = array_filter($parts, 'find_closed'); // find only the closed status if(empty($result)){ echo "Item is not closed"; } else { // is closed, get the date list(,$closed) = explode('\. -- ',current($result)); echo "Closed date: $closed<br />"; list(,$day,$month,$year,$time,$ampm,,) = explode(' ',$closed); $datetime2 = new DateTime("$day $month $year $time $ampm"); $start = "2009-07-23 14:00:06"; // your created date ----------------------------------------------------------- $datetime1 = new DateTime($start); $interval = $datetime1->diff($datetime2); $array = array("y"=>"Year","m"=>"Month","d"=>"Day","h"=>"Hour","i"=>"Minute","s"=>"Second"); foreach($array as $key=>$value){ if($interval->$key > 0){ $plural = $interval->$key > 1 ? 's' : ''; echo "{$interval->$key} $value$plural<br />"; } } }
-
Unless you have a definition of what it is you want to achieve, its not possible to write code to do it. Do you want to display the elapsed time between each change in status, between specifically named statuses, between the first and latest status and what do you want the output to be?
-
Is a sessions database needed .... ?
PFMaBiSmAd replied to floridaflatlander's topic in PHP Coding Help
Using a custom session save handler to store the session data in a database is only really an advantage when your site is busy enough to have two or more (load-balancing) web servers, that must have access to the same session data. -
Unless a person is dead, their age is not a constant number. It changes once a year on their birthday. You need to store the date of birth and then to find age ranges, perform a date comparison that corresponds to the correct birthday date range calculated relative to the current date.
-
Sorting Multidimentional Array by two Indexes
PFMaBiSmAd replied to xProteuSx's topic in PHP Coding Help
In general, you would use array_multisort - <?php // Obtain lists of column values to sort by foreach ($superarray as $key => $row) { $index1[$key] = $row[1]; $index2[$key] = $row[2]; $index3[$key] = $row[3]; } // Sort the data with index1 asc, index2 asc, index3 asc array_multisort($index1, SORT_ASC, $index2, SORT_ASC, $index3, SORT_ASC, $superarray);