Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by PFMaBiSmAd

  1. Since we are bumping this (already solved) thread - a solution using mktime/date has already been posted and it's been pointed out that using mktime/date doesn't work for people born before 1970 or 1901 (depending on php version and 32/64 bit operating system.) Topic locked...
  2. The output from your sessionstart.php file doesn't match the posted code above. Are you sure what's actually in that files? Could you post the sessionstart.php file again. Are you using any foreign language characters (non ASCII) or any control/non-printing in the 'test' array index name, so that what is actually showing in your file isn't what is being shown in your posts in the forum? We have seen times where the copy/paste into the forum post produces 'clean' code that works, but there is something in the actual code file that doesn't match. Try deleting the ['test'] portion of the $_SESSION variable and retype it. When I visit your two pages, I get the same session id cookie value on both pages. That indicates that the session_start on both pages is starting/resuming the same session data, but the ['test'] index isn't present on the 2nd page. There may be an issue with the server where the file name is being created, but the actual file isn't (there is typically a php error when this type of thing occurs.)
  3. Do you have php's error_reporting set to E_ALL and display_errors set to ON so that any session related errors will be reported and displayed? You could have a session.save_path problem or a header error due to your file's character encoding containing the BOM (Byte Order Mark) characters.
  4. @cyberRobot, at the top of the page, means before you output anything to the browser - Your code worked, because php has a setting, mentioned by kicken in this thread, that hides incorrectly coded pages, but results in code that is not portable between different server configurations and should be avoided.
  5. That's not shown in the code you posted and we only see the information that you post.
  6. Nope. By injection sql with something like ' OR id=1, a hacker can make your query match any row in your table. Your query would become - SELECT * FROM users WHERE token='' OR id=1
  7. ^^^ That would imply that you are trying to put the posted code onto a web page. You cannot output anything on a web page besides the html/css/javascript. Any force-download/dynamic image must be output as a completely separate response by putting a link to the force-download .php code into your html markup on a web page. What's the actual code on the page that doesn't work? Also, how exactly did you turn on error_reporting/display_errors and did you confirm that they actually got changed by intentionally producing an error?
  8. The general fix for your logic would be to put the form processing code into a specific section of code that - tests if the form has been submitted, validates the inputs, then saves the submitted post data to session variables. Empty post data would be saved as an empty string to the corresponding session variable. In the form code for the value='...' attributes, if the corresponding session variable isset, meaning that the form has been submitted one or more times, you would use it's value, which could be an empty string, else use an empty value.
  9. Your forgot to tell us what error or symptom you saw in front of you that leads you to believe your code isn't working. Without that information, since we are not standing right next to you, it's a little hard to narrow down the dozen different things that could be wrong with any piece of code to the one or two actual things to check.
  10. This is secondary to the problem you are having, but by putting the $row_id variable directly into the query being prepared, you are allowing sql injection, not preventing it. One of the main points of using prepared query statements is to prevent sql injection. You would put a place holder into the query for the id value, then supply the actual value at the time the query is executed. Edit: ^^^ Which I had already posted at the end of your last thread - http://forums.phpfreaks.com/topic/271784-show-row/#entry1398388
  11. Topic locked to prevent replies that should be in the original thread. @jazzman1, I moved your post from this thread to the original thread.
  12. If you are getting a notification email with a problem with the link in it, please start a thread in the PHPFreaks Questions, Comments section - http://forums.phpfreaks.com/forum/23-phpfreakscom-questions-comments-suggestions/ Copy/paste the link from the notification email so that an admin can find what is wrong with it.
  13. Your thread didn't disappear, unless you mean that you couldn't find it by looking under your profile (which doesn't work as it should) - http://forums.phpfre...configphp-file/
  14. If you look at the code I posted, you will see that I modified the code in his function to use the modified data structure. In fact, the code I posted is a working example. Put it into a .php file and play with it to see what the code is doing.
  15. You should define the fields (legend text, field name, field type) in an array (or a database table), then simply loop over the list of field definitions and build the form using php code.
  16. Change - $data[$parent][] = array('id'=>$id, 'name'=>$name, 'number'=>$number); To - $data[$parent][$id] = array('name'=>$name, 'number'=>$number,'total'=>0);
  17. The data would be in an array or a database. Then you would use the entered value to loopup/find the result.
  18. That comes from the column name that was selected in the query statement. Unfortunately, someone broke a rule of clear code writing and used the extract statement to magically produce php variables in that code. You would normally, and less magically, use $row['product'] in that code.
  19. You would need to iterate over the data to produce the totals, then display the result - <?php // sample data - $data[null][1] = array('name'=>'Europe', 'number'=>0,'total'=>0); $data[1][2] = array('name'=>'BG', 'number'=>8,'total'=>0); $data[2][3] = array('name'=>'Sofia', 'number'=>5,'total'=>0); $data[2][4] = array('name'=>'Varna', 'number'=>2,'total'=>0); $data[3][5] = array('name'=>'Mladost', 'number'=>4,'total'=>0); $data[4][6] = array('name'=>'Chaika', 'number'=>9,'total'=>0); // additional test values - /* $data[2][7] = array('id'=>7, 'name'=>'abc', 'number'=>1,'total'=>0); $data[1][8] = array('id'=>8, 'name'=>'def', 'number'=>3,'total'=>0); $data[8][9] = array('id'=>9, 'name'=>'defg', 'number'=>5,'total'=>0); $data[null][10] = array('id'=>10, 'name'=>'ghi', 'number'=>0,'total'=>0); $data[10][11] = array('id'=>11, 'name'=>'ghijlk', 'number'=>33,'total'=>0); */ // this function produces the totals only function totalHierarchy(&$arr, $parent, $bc=''){ if (isset($arr[$parent])) foreach($arr[$parent] as $id=>$rec){ // form a bread-crumb to reference the total elements $p = is_null($parent) ? 'n':$parent; // convert the null parent to a value that can be seen for debugging $bread = ($bc != '') ? '|' : ''; // make bread-crumb (the incoming $bc value is not altered so it has the correct value for the duration of the loop at any recursion level) $bread .="{$p}_{$id}"; // form bread-crumb for the current recursion // add number to appropriate totals - $parts = explode('|',$bc.$bread); // the existing bread-crumb + bread-crumb for the current recursion foreach($parts as $crumb){ list($indexa,$indexb) = explode('_',$crumb); $indexa = $indexa == 'n' ? null : $indexa; // convert the 'n' back to null $arr[$indexa][$indexb]['total'] += $rec['number']; } totalHierarchy($arr, $id, $bc.$bread); } } // this function displays the information function displayHierarchy(&$arr, $parent, $indent=0){ $ind = $indent * 30; if (isset($arr[$parent])) foreach($arr[$parent] as $id=>$rec){ echo "<div style='width:300px; margin-top:5px; margin-left: {$ind}px; padding:5px; border:1px solid gray;'> {$rec['name']} - {$rec['total']} </div>" ; displayHierarchy($arr, $id, $indent+1); } } // call the recursive total function totalHierarchy($data, null); // call the recursive display function displayHierarchy($data, null);
  20. Your repost of this in the php forum section has been removed. Where exactly is the onclick= ... statement in the HTML on your page, because you cannot just put it in the middle of nowhere. It needs to be inside the HTML tag of something that can be clicked on - i.e. show us the actual code that reproduces the problem that you need help with.
  21. You would use a counter to determine when you close out one row and start the next - http://forums.phpfreaks.com/topic/11572-multi-column-results/
  22. There's almost never a reason (good or bad) to perform queries inside of a loop. You need to - 1) Execute one query that gets the records you need for one complete page. If you are trying to display data for one day, you would retrieve all the records that match that year/month/day. If you are trying to display data for one month, you would retrieve all the records that match that year/month. 2) Fetch all the records that the query matched and store them into a php array, using the datetime of the record as the array key. If you can have more than one 'event' on any datetime, you would make a two-dimensional array. $data = array(); while($row = mysql_fetch_assoc($dbslottimes)){ // if there can be only one event per datetime - $data[$row['your_datetime_field_here...']] = $row; // if there can be more than one event per datetime - $data[$row['your_datetime_field_here...']][] = $row; } 3) As you loop through the datetime slots to produce your output, form a datetime value of that datetime slot (in $datetime for the following sample code) and use that value to test/reference any data in the array you formed in step #2. To just test if there is data, you can use isset($data[$datetime]) or array_key_exists($datetime,$data). To reference the data - // if there can be only one event per datetime - if(isset($data[$datetime])){ echo $data[$datetime]['some_field_name_here...']; } // if there can be more than one event per datetime - if(isset($data[$datetime]) && is_array($data[$datetime])){ foreach($data[$datetime] as $row){ echo $row['some_field_name_here...']; } }
  23. When using the GET method for a form, the only get parameters that are put into the URL are from the form fields. You would need to use hidden form fields to pass any existing get parameters.
  24. Ummm. If your purchased code has a copyright by the author that prevents you from publishing/distributing it, which is likely, don't post it. Get help from the author.
  25. You would also need to tells us what symptom or error you got that leads you to believe that something doesn't work as expected, because we are not standing right next to you and don't know what you saw in front of you.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.