-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
WP offers several sanitization functions - looks like you need sanitize_file_name().
-
Call to undefined method in included file
maxxd replied to richarddunnebsc's topic in PHP Coding Help
I agree with and you should heed both benananmen and gizmola's points. But for your specific question here looks - as ginerjm points to - like a question of scope. For instance, as you (I assume) learned fixing the database connection, you couldn't use $user or $pass variables within the __construct() method because you didn't pass those variables to the __construct() method. Every variable, method, and function (with some limited and typically ill-advised exceptions) has a scope outside of which it doesn't exist. So, look at where you define $data - is it in the same scope as where you use $data? Was it in the same function, or was it passed to the function that's trying to use it? -
That's kind of just a wall of poorly formatted code, so it's hard to tell where the actual problem is but let us see the GetPosts() method. What you're describing should be a data gathering concern, not a display concern. Other unsolicited advice - your entire comment output should be a method of it's own; right now the two blocks are almost identical. And I'm assuming the poor formatting is due to copy/paste issues, but on the off chance that it's not then fix that as it'll make reading your code much easier.
-
You can't make it work without altering the code you already have. Your code doesn't take pagination into account, so in order to use pagination you must alter your code. You'll need to add a LIMIT clause to your query, then add links that target the same page with an updated starting record ID. When your page is loaded, check to see if that start number is set - if it is, it becomes the new starting offset in your SQL limit clause. If it doesn't exist, the starting offset is 0. That should be enough to put you on the right path - give it a shot and if it doesn't work post your code here with your questions.
-
We don't know what the rest of your code looks like, so it's difficult to say what's actually happening. My biggest question is is there a reason you're not using one of the many existing PHP template engines? Personally, I'm partial to Twig when not in Laravel land.
-
CSS <h1> & <p> class problem. Line changing/spacing
maxxd replied to PeterBubresko's topic in CSS Help
In addition to the box model, there's semantic web markup wherein the tags define the structure of the page and how important individual elements are - this is important in many different ways to many users. I think this is what everybody so far has been getting at - note that Barand used a span with the class 'headline' instead of an actual h1 tag and requinix pointed out that headings and paragraphs aren't meant to be displayed inline. It's based on the box-model structure that gizmola linked to and (i believe) informs the standard coding practices that Strider64 is talking about. This is by no means a complete explanation of the concept, but it's a decent place to start - https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Document_and_website_structure. -
A few things. Are you using NuSOAP? If so, the class name is `nusoap_client`, not `soapclient`. Also, please explain "And put it next to the project.". What's the value of APPPATH, and is the nusoap.php file in the folder `APPPATH.'Controllers\Payment\lib`?
-
@gizmola - I am actually copying a composer.json file into the container and trying to run it, but it points to private bitbucket repositories and it's there that I'm running into issues. Thanks for the link and I'll let you know how it goes!
-
A span's default display value in a browser is inline, so unless there's a reason to change it it should do what you want natively. As requinix pointed out, if it's there it may be used - try adding a helper class and overriding the display to 'inline' on that class.
-
No, I'm just being a bit lazy and misusing the term. I mean core PHP objects and classes.
-
Well crap. Back to Google - thanks, requinix!
-
I am on a mac and I believe the path is correct. I've seen ssh-agent as the volume mount and tried that as well, but still nada. The one thing that's been consistent in my searching is the environment variable name - were the comments you saw about that or the mount path?
-
Missed that entirely - my bad.
-
It could just be nested indexed arrays. So instead of foreach($employees as $employee) { echo "Name: {$employee['name']}<br>"; echo "Department: {$employee['department']}<br>"; echo "Salary: {$employee['salary']}<br>"; } it would simply be foreach($employees as $employee) { echo "Name: {$employee[0]}<br>"; echo "Department: {$employee[1]}<br>"; echo "Salary: {$employee[2]}<br>"; } Not the best pattern or most readable code, but if it's early days in the class it could get a lesson about array access across. Edit: this is assuming the array declaration in the initial comment is from the instructor as the system input.
-
Not sure what's the best place for this, so mods please feel free to move it somewhere more appropriate. I'm having literally no luck forwarding the SSH agent from my host machine to my docker images. I'm trying to set up an image that can use composer to pull several private bitbucket repositories. My docker-compose file includes a composer:2 service, shares volumes with my main app service, sets an environment variable SSH_AUTH_SOCK to /ssh-auth.sock, and mounts that volume to /ssh-auth.sock in the built container. No dice. After several days of not being able to do it via docker-compose I copied and pasted the exact code from the official docker Composer image: eval $(ssh-agent); \ docker run --rm --interactive --tty \ --volume $PWD:/app \ --volume $SSH_AUTH_SOCK:/ssh-auth.sock \ --env SSH_AUTH_SOCK=/ssh-auth.sock \ composer install and tried it without docker-compose; I got the same please make sure you have access to your private bitbucket repository error as I get in my compose file. I know this can work, but every example of it working doesn't actually work in my case so I assume I'm missing something... Anybody have any ideas or advice?
-
I'm not familiar with Symfony, but yeah - rules are made to be broken, right? There are situations where a tighter coupling is not entirely unavoidable, but honestly is just easier and in the long run is not a terrible idea. Instantiating SPL objects in a class constructor is really not that awful IMO as SPL objects are unlikely to change massively without a good amount of forewarning. It can be annoying when a library comes out that does something similar to the SPL class easier, but by then you've already got the SPL code working so ... so?
-
None of what you've given us makes sense given what you say the problem is. Assuming the line of code you say you're using: let searchParams = new URLSearchParams(window.location.search); var status = searchParams.get('source'); actually is in your code - it doesn't appear in any of the code you posted - you still don't send the variable 'status' (which theoretically includes the value of the URL parameter 'source', not 'status' as the variable name implies) to $site_url()/reports/loadLeads. Also, you need to send an AJAX call to a php script (that ends in .php) and from there you can call a function - you can't call the actual php function from the URL string. And even if it did work that way, your loadLeads() method only accepts one parameter (which, admittedly, it doesn't seem to actually use), but your JS data object contains two. There's more beyond this, but quite honestly you need to take a step back and pick up some basics. Learn to walk before you run - I remember learning AJAX back in the day and it made no sense whatsoever until I'd done enough base-level work to actually get it. The penny dropped and it hasn't been a problem since.
- 1 reply
-
- php
- codeignitor
-
(and 1 more)
Tagged with:
-
There's no AJAX calls in the code you've posted. If you think the error is there, perhaps post it for us to take a look. If you're using the index method for your AJAX calls (again, we don't know as we can't see the call) then it could be that it's borking because you're trying to render the entire template file instead of returning the pertinent data from the query.
- 6 replies
-
- 1
-
- codeignitor
- php
-
(and 1 more)
Tagged with:
-
What is redirect_m? I don't recall it from codeigniter and don't see any references to it in the docs. You're treating it like a db abstraction layer which is confusing given the name.
- 6 replies
-
- codeignitor
- php
-
(and 1 more)
Tagged with:
-
So Barand did all the work and made a useful working script under the impression he was not only helping you with a personal project but helping someone who wanted to learn PHP. You then removed all public-facing attribution to Barand and broke the system, turned around and tried to sell the software he built and you broke, and now you offer him a 50-50 split but you can't understand why he's miffed about it? I mean, dude...
-
@Barand I've always thought you were too kind by half; I guess no good deed goes unpunished, eh? OK, given the history I'm out. Enjoy, Leon.
-
That's a ton of code - does it work? Does it throw an error? What does it do, and what is it supposed to do?
-
As an aside, please use the code button in the post composer to paste code (it's between the quotes and the smiley face - "<>"). It helps with formatting and as long as you select PHP in the language drop-down on the right, it'll color-code your code and make it much easier to read.
-
You won't necessarily be able to see the whitespace - depending on what IDE and character set you're using there may be an errant byte order mark in the output or there may just be too many includes to thoroughly trace. And just because you deleted opening/closing PHP tags in header.php doesn't necessarily mean that's it. For instance, you have a couple open/close tags in login.php and you don't show the full code of marina.php. Basically, if you have unbroken blocks of PHP, don't break up the blocks. There's no need to go in and out of PHP unless you absolutely have to, and nine out of ten times you don't. Unless you're using WordPress or an old-style or homegrown framework, in which case you will have to so be aware that it's not a great way to develop and keep a close eye on your code.