Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. You need to attach a click event to the buttons, not to the submit event on the form.
  2. You need to install the ODBC extension on your system. For example, with apt install php-odbc on something Debian based should do it.
  3. It would help if you posted the associated HTML and any other css needed to create a demo of your issue. Creating a fiddle showing the issue would be great for example as it makes it a lot easier for others see the issue and to try possible solutions.
  4. Assuming mysql, Your tables may be using the MyISAM engine which does not support transactions. You should be using InnoDB unless you have a specific reason not to.
  5. Typically mass imports are something that wouldn't be done via a web request. The task would be offloaded to a background task (through a cron job or task queue system) where you don't have to worry as much about timeouts. For example, for simple things I've typically inserted an import job into a table in the database with whatever information is needed for the import process. Then a second script run via a cron job on some interval checks that table for new import tasks and if one is found, performs the actual import task. This way the user isn't stuck with a loading page for however long the import takes, and the import task isn't subject to any timeouts other than PHP's max_execution_time settings (which is unlimited by default for CLI scripts).
  6. Your file has a invalid character in it that needs to be removed. Try deleting the line and re-typing it. Don't copy/paste or you'll copy/paste the character as well.
  7. The code to load your data seems to all be the same, so put it into a function and just call that function when you need to load the data. Your if(pageLink == "approverequest") { test seems pointless also since both branches do the same thing, so remove it. function loadProjectRequests(){ $("#requests-container").html( "<div class=\'col-sm-12 py-5\'><center><i class=\'fas fa-spinner fa-3x fa-spin mb-3 text-muted\'></i><br /></center></div>"); $("#requests-container").load("'.DIR.'admin/dashboard/requests", function(){ $("#project-requests").DataTable({ "order": [[0, "desc"]], "responsive": true, "lengthChange": true, "autoWidth": false, "pageLength": 25, "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], "buttons": ["copy", "pdf", "print", "colvis"] }).buttons().container().appendTo('#project-requests_wrapper .col-md-6:eq(0)'); $("#project-requests_wrapper").children(":first").addClass("p-2"); $("#project-requests_wrapper").children(":first").next().next().addClass("p-2"); }); } $(document).ready(function(){ loadProjectRequests(); }); $(document).on("click", ".action-requests", function(e){ e.preventDefault(); var Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 5000 }); var pageLink = $(this).attr("href"); var requestId = $(this).attr("data-id"); $.post("admin/dashboard/queries/" + pageLink, { id: requestId }, function(data, status){ if (status === "success"){ Toast.fire({icon: "success", title: data}); loadProjectRequests(); } } ); });
  8. Line 113: <option value="<?=$PreviouseYear ?>" <?php if ($SE_YYYY_Entry == $PreviouseYear){ ?> SELECTED <?php }? > ><?=$PreviouseYear ?></option> Your closing PHP tag is malformed.
  9. I've never used it personally but I've heard good things about rector.
  10. Is whatever server is running on port 80 using the same domain? Let's encrypt doesn't all alternate port numbers so you either need to be able to validate the domain using the server on port 80, or use an alternative verification method such as DNS verification. Once the certificate is validated on port 80, you can use it with other ports just fine.
  11. As a general recommendation, you could instead create a class that applies the display: none; style then use toggle. .removed { display: none; } function showDiv(divid) { document.getElementById(divid).classList.toggle('removed'); }
  12. I'm assuming you mean a mobile app. I'd ask if you actually need an app vs just a mobile friendly website. Making the website mobile friendly would probably be easier. You could give it a manifest file and users could even add it to their home screen as if it were an app.
  13. Because you are only counting extras if they were not expected at all ($expected_counts[$sku] is not set). Your extra 3333 item was an expected sku, you just got too many. Your code can be much simpler by just calculating the counts of expected vs received for each sku rather than doing your array_fill stuff and checking index existence. $all_skus = array_merge(array_keys($expected_counts), array_keys($received_counts)); $reconciled = []; foreach ($all_skus as $sku){ $reconciled[$sku] = ($expected_counts[$sku] ?? 0) - ($received_counts[$sku] ?? 0); } $reconciled = array_filter($reconciled); First get a combined list of all possible SKUs, then loop over that list and for each SKU calculate # of expected (0 if unexpected) - # of received (0 if none received). Finally, filter out all the entries that ended up as 0 (received and expected match). You're left with an array of SKUs with either positive (missing) or negative (too many) items. If you really need an array of SKU's, you can expand the reconciled array out as necessary.
  14. Not just start the file with. Every PHP code block must use <?php (or <?= for the short echos). The Statement.php file you just uploaded contains blocks where you did not fix this issue. Line 101 <? $stmt = GetAllData($Date); echo $stmt; Line 156 <? } else { ?> Line 161 <? } ?> Line 174 <? } ?> You need to fix ALL of these tags. Do so in ALL of your files.
  15. You should probably have SSH access to the server then. Use that to access a shell and you should have access to the mysql and mysqldump tools, they are pretty standard.
  16. I hope that's a typo and you mean 7.4. Either way, you need to upgrade, but if you really are on 4.4 then you need to upgrade like, yesterday. Having a user that can access both databases would allow you to use the INSERT query you tried. If you're on shared hosting, you probably won't have the ability to do that. If you're using your own server, then presumably you'd be able to use the root user to run the query or adjust the privileges. Assuming this is a one time thing, or just once in a while thing, then the best option with separate users would be to access the command line if you can and use mysqldump command to dump the table from the first database, then use the mysql command load the generated sql file into the second database.
  17. Sounds like you just want an update query. For example update users_table set reqid=75 where username='joe' If that's not what you want, then you may need to try and explain again differently.
  18. In order to use step debugging, xdebug.mode needs to contain debug. If it still does not work after adding that, try setting xdebug.start_with_request to yes. I have not used either sublime or that browser extension, so not sure if they need anything special.
  19. Before anything else, you need to add an ORDER BY clause to your query so that you can ensure a consistent order of your results. Without an ORDER BY clause, the database server is allowed to return the rows in whatever order it wants, usually that's just whatever order it finds them in as it scans the indexes/tables. As you add/remove data that order will change. Once you have your results ordered in a specific way, you can count the number of records that come before a specific row by running a query with a where condition of theOrderByColumn <= yourCurrentRowsOrderByColumn. For example. SELECT id,path, subCategoryId FROM `files` WHERE categoryId=5 AND subCategoryId=15 ORDER BY id; SELECT COUNT(*) FROM files WHERE categoryId=5 AND subCategoryId=15 AND id <= 307
  20. You are still using a short tag in that file. </div> <? <------- here $stmt = GetAllData($Date); You need to go through all your files and replace those short tags with proper <?php tags.
  21. That's not really the intended way to use this stuff. The intention is more like this: main.php <?php spl_autoload_register(); $app = new Application(); $app->run(); application.php <?php class Application { public function run(){ echo 'Running my application!', PHP_EOL; } } Then run main.php $ php main.php Running my application! Calling spl_autoload_register tells PHP to use the default autoloader (spl_autoload) when it needs to autoload a class. When PHP tries to process the new Application code, it sees that the class Application is undefined, so it calls the registered autoload functions to try and define the class. The standard autoloader function takes the class name, makes it lowercase, then tries to locate the file using the registered extensions in the defined include paths / current directory. If you just have a specific file you want to include, then you don't need to deal with the autoloader, just use include or require directly.
  22. PHP calls the autoload function when it encounters a class name that it does not know. The job of the autoload function is to define that class, usually by including the file which contains it. It means that if you call spl_autoload_register(); //Note, no parameter is passed. without providing a function, it's treated as if you had called spl_autoload_register('spl_autoload'); The default autoload function does this in a simple way, it basically takes the class name, converts it to lower case, then checks if a file with that name + an extension exists and if so, includes it. You can control which extensions it checks by using spl_autoload_extensions. You control which directories it looks in using the include path. If you need more complex logic or control for loading your class files, then you would provide your own autoload function rather than use the default one.
  23. I'm not familiar with CI3, but assuming it has a single entry point file, it'd probably be best to add an explicit check there rather than in places your DB is used.
  24. Arrays are accessed using square-brackets, not parenthesis. That change should have been to $param[0] You don't name the function spl_autoload_register, that is a predefined function that accepts a callback. I'm assuming your original code looked like this: if ( ! function_exists('__autoload')) { AutoLoader::addFolder(array(APP_PATH.DIRECTORY_SEPARATOR.'models', APP_PATH.DIRECTORY_SEPARATOR.'controllers')); function __autoload($class_name) { AutoLoader::load($class_name); } } To update it, the easiest thing to do would be to rename the __autoload function to something unique for your application, then call the built-in spl_autoload_register function with that new name. You can also remove the if statement as it's no longer needed. AutoLoader::addFolder(array(APP_PATH.DIRECTORY_SEPARATOR.'models', APP_PATH.DIRECTORY_SEPARATOR.'controllers')); function my_app__autoload($class_name) { AutoLoader::load($class_name); } spl_autoload_register('my_app__autoload');
  25. I'm not really sure what you're after, and your code is not very easy to understand. Your screenshots all seem basically identical to me so that doesn't help clear things up either. Is the goal to only show the "settings button" next to specific items? I'd suggest you start with just trying to clean up your code to make it easier to understand and improve the formatting. Your pages array for example should be using all named keys rather than a bunch of numeric ones and a couple named ones. That way it'll be much clearer what all the settings are for each item. A more advanced improvement may be to replace the array's with an object with properties, but just adding named keys would be good enough for now. Something like: $pages = [ [ 'name?'=>'overview', 'label?'=>$lang->line('lm_overview'), '???1'=>'', '???2'=>'FFF', '???3'=>'', '???4'=>'1', '???5'=>'1', 'second_button' => true, 'button_enabled' => true ], ... ]; $second_button_pages = [ [ 'name?'=>'empire', 'label?'=>$lang->line('lm_empire'), '???1'=>'', '???2'=>'FFF', '???3'=>'', '???4'=>'1', '???5'=>'1' ], ... ]; I labeled them all with a ? because I honestly have no idea what those elements are for. Giving them a descriptive key name would solve that and make your code much easier to read and understand. Think about when you come back to this in 9 months and need to add a new menu item, the way it is now you'll have no idea what data to put in the array or where. In your template file, the indentation could be improved. Make sure the content that is within a conditional is indented to be within that conditional, right now it's kind of all over the place. You also seem to have unnecessary conditions, possibly related to the poor indentation. Notice you are checking if $main_button is true when you're in a branch that has already determined that it's true. That check is unnecessary. Your check of $snd could be unnecessary. If $snd is an empty array, the foreach loop will do nothing and thus not output anything, so there is no need to check that it's not empty before hand. Checking if $button is true is also probably unnecessary, as you probably just shouldn't be putting any empty values into your $snd array in the first place. If you take all that out, your template code is much simpler. You should also be moving your style="" stuff into classes and just apply the class to simplify the template even more. <table> @if ($main_button) <tr> <td style="display: flex;flex-direction: row;flex-wrap: nowrap; justify-content: center;"> <div class="holo-container" style="background-image: url('public/upload/skins/xgproyect/menu/holomen.png'); background-size: contain;"> <span> {!! $menu_link !!} </span> </div> <div> @foreach ($snd as $button) <a href="{{ $button[0] }}" style="color: #fff"> <button class="holo-button" style="right: 25px; position: absolute; background-image: url('public/upload/skins/xgproyect/menu/sbutton.png'); background-size: contain; width: 32px; height: 32px; background-color: #fff0; border: none;"> <img src="public/upload/skins/xgproyect/menu/cog.svg" alt="Cog Icon" style="width: 100%; height: 100%; filter: invert(100%);"> </button> </a> @endforeach </div> </td> </tr> @endif </table> You also probably shouldn't be using <table> for this, and you shouldn't be using <font> either for your links. For your list of menu items you'd probably want <nav> containing a <ul> and a <li> per button. For the button text, put a css class on the span tag that controls the color. Take a pass at cleaning things up, then try posting again to explain what you want and better screenshots of what you want to see vs what you are seeing if you still have issues.
×
×
  • 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.