Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by kicken

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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');
  14. 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.
  15. No, it does not. PHP doesn't do CORS. You can make whatever request you want to whatever destination you want with PHP. CORS is something implemented by browsers to restrict JavaScript's ability to create requests, it has no affect on server-side requests like those made from PHP, Python, NodeJS, etc.
  16. I don't think their API works like a traditional one where you just hit a URL. They seem to open a websocket connection to a server and then issue requests to it for the API. You would probably have to re-implement that in PHP, which would probably just have to be done by reverse engineering their code. Searching packagist shows one package that might already do this: https://packagist.org/packages/sergix44/gradio-client-php. You could try that package first. Otherwise, the easiest thing to do might be to use either their python or JS packages to make a script that does what you need, then interface with that script using PHP.
  17. Seems like you're outputting both HTML content and your exported CSV in the same request. You cannot do that. Whatever request is being made to export the CSV data needs to only output that CSV data, no HTML content.
  18. Look at the documentation for getAttributes(). There is a flags parameter which is where you use the IS_INSTANCEOF constant.
  19. Your code isn't that far off. imap_sort gives you a list of message numbers after the sorting has been applied. You have that list split into pages using array_chunk. Take the page you want and fetch those messages. The second parameter to imap_fetch_overview is how you specify the messages you want to fetch, and documented as: So to fetch arbitrary messages, specify them as a comma-separated list of message numbers. To do that, you can just implode your page of numbers that you get from the array_chunk result. There is a lot of stuff in your listMessages function that is not necessary and can be removed. After cleaning up the function and adding the call to imap_fetch_overview, the function would look like: function listMessages($inbox, int $page, int $perPage) : array{ $sorted = imap_sort($inbox, SORTDATE, 1); $pageList = array_chunk($sorted, $perPage); $messagesToFetch = implode(',', $pageList[$page - 1]); $details = imap_fetch_overview($inbox, $messagesToFetch); return array_reverse($details); } You can then use it to fetch a page of messages and display the summary info. $messages = listMessages($inbox, $page ?? 1, 25); foreach ($messages as $item){ $number = $item->msgno; $date = $item->date ?? 'Unknown'; $subject = $item->subject ?? ''; printf("[%d] %s - %s\r\n", $number, $date, $subject); }
  20. Your analyzePage function is not returning a value, so your $analysis variable will be null. If you have PHP's error reporting turned up all the way, and are on a modern version of PHP, you should be seeing a warning about not being able to use foreach on a null value. On an unrelated note: This could simply be return $content; There is no need for the check against false there since if it is false, you will just return false.
  21. You don't, because such a thing doesn't make sense to do. How about you describe the problem you think this will solve? Sounds like maybe what you want instead is either a sequence or an identity column.
  22. PHPSpreadsheet uses a lot of memory, about 1.6KB per cell according to the docs. If I did my math right, you spreadsheet contains just over 2.3 million cells, meaning it will require roughly 3.7 Gigabytes of memory just to load the data in the cells. Even more for the various other things your script is going to be doing. The documentation linked above talks about ways you can implement a cache to try and conserve memory. You can also adjust the settings to load only data and apply a filter to control which data is loaded. The best option, in my opinion though, is to abandon trying to read actual excel files and instead generate and read CSV files. You can easily convert your worksheet to a CSV by opening it in Excel and re-saving it as a CSV, then upload that to your import script. You can then read this CSV file line-by-line and only use as much memory as a single line requires.
  23. Accept the incoming data using the appropriate superglobal variables, then use the header function to output a Location header to the desired URL. Your current form is formatted well for this, so first you'd want to change it to give your select box a meaningful name, and remove your hidden input as it is not necessary. $result = mysql_query($sql); echo " <form id='myForm' action='https://mywebsite.com/forum/index.php'> "; echo '<select name="city">'; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['field_181'] ."'>" . $row['field_181'] ." - " . $row['COUNT(field_181)'] . " Events </option>"; } echo " </select> "; echo " <br><br> "; echo " <input type='submit'> "; echo " </form> "; Then in your index.php file, you need code to detect if the city input was submitted and if so, issue the redirect with header. if (isset($_GET['city'])){ $url = '/forum/index.php?/'.urlencode($_GET['city']).'-bowling-tournaments/'; header('Location: '.$url); exit; } I don't see much point in doing this though. If you want pretty URLs you should use URL rewriting or a Router library. Otherwise, just use normal query parameters/form posts. Pretty URLs are not necessary, they are just a nice touch.
  24. Why do you think that? That is not how forms work. Form data is submitted in name=value pairs, each pair separated by an &. What you're getting is exactly what you should be getting. If you want the other URL format, then you need to either Write JavaScript code to read the form and redirect to the desired URL or Accept the standard format form data with your PHP code, and issue a redirect based on the submitted data.
  25. This is where the misunderstanding of what attributes are and are for seems to come in. Attributes apply to the class itself. The only way to make a connection between a specific instance of a class and that classes attributes is when you use reflection on the instance to look up it's class and associated attributes. This process only works one way: instance -> class -> attributes. You cannot go backwards the other way: attribute -> class -> instance.
  • 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.