-
Posts
15,290 -
Joined
-
Last visited
-
Days Won
436
Everything posted by requinix
-
How do I insert multiple checkbox data as 1 or 0 in multiple columns?
requinix replied to ke-jo's topic in PHP Coding Help
How about you go back to using an array? I don't understand why you had to change that. It was fine. -
Ajax Post Data to Jquery Datatable and Return Another Value
requinix replied to jarvis's topic in Javascript Help
The thing you pass as the "ajax" value needs to be a function. It take a few arguments, as seen in the documentation, and when it's done it uses the callback function it received. What code do you have trying to do that? What do you expect to happen when you view the table and what actually happens? -
Ajax Post Data to Jquery Datatable and Return Another Value
requinix replied to jarvis's topic in Javascript Help
So what you need is to be able to customize how the DataTable does the AJAX request, right? You can perform the actual request yourself, then give the DataTable just the "example" data while you borrow the "search-results-header" data for something else. When in doubt, check the documentation. -
Ajax Post Data to Jquery Datatable and Return Another Value
requinix replied to jarvis's topic in Javascript Help
What? Do you want to add that markup to the page? Or are you trying to return a value from PHP that should be inserted into that DIV which is already written on the page? -
How do I insert multiple checkbox data as 1 or 0 in multiple columns?
requinix replied to ke-jo's topic in PHP Coding Help
A checkbox is only submitted when it is checked. You cannot simply look at [0] and [1] and so on to know what value it has. The answer is, hopefully not too surprisingly, to look at the value. You've got it right there. fruit_selection will be an array and all you have to do is see if that array contains each fruit. -
I'm not sure there even is anything wrong. Not with the code. You know what this thing does, right? You feed it a nickname and the script looks for IP addresses it used, then for each of those it finds nicknames, then for each of those it finds IP addresses, and so on until it runs out of stuff. You searched for "Matej_Cizik"? Look in the database table yourself for that nickname. Does any of the data seem to be off? Then try searching according to the IP addresses you just found. Then those nicknames. Does it seem to be spiraling out of control?
-
Programming isn't like piecing together LEGO blocks. You can't just go onto the internet and get an "admin dashboard" component and shove it into your application. If you're working with WordPress or some other cookie-cutter framework then there might be a plugin out there to do what you want. Otherwise you'll probably have to (gasp) learn some PHP and HTML and CSS. Because it's not like there are people out there who know your website and are climbing over each other to write free stuff that will work with it in the hopes that you'll go download their thing.
-
The #1 way to have vulnerable code is to copy and paste what you find on the internet. There is no substitute for learning PHP and secure coding practices. That said, the thing you found is actually one of the safest versions I've seen in that it does not fall prey to any of the common problems that plague most of what you'll find online. Would be nice if they talked more about it, tried to address issues like file permissions or access control, but I suppose this is one of the few good examples of w3schools doing things right. Good developers write good code. Bad developers write bad code. Language has nothing to do with it.
-
Make an upload script. The internet has a lot of resources to help with that. Be careful that you don't allow anybody who stops by to upload anything they want. Put the files somewhere not accessible through your website with a regular URL. Make a download script. Specifically, you need a PHP script that will download the requested file to your browser. Also lots of resources to help with that. URL rewriting would help. Then update that download script so it deletes the file after sending its contents.
-
Check your variable names. By the way, when a word is plural that normally means there is more than one, and the singular version is when there is just one.
-
->fetch() only gives you one row at a time. If you look at what's available to use you'll probably find something more like what you're expecting.
-
You're much more likely to get some help if you can show some initiative on your part first. Like, if you've tried writing the code yourself. Or if you have something partially done to show and don't know how to continue with it.
-
Print image to receipt printer from PHP on Windows
requinix replied to siric's topic in PHP Coding Help
You'll have to do that. Educated guess says the image has to be a monochrome (B&W) bitmap. -
All you have in that array is the firstname. That's not unique. You need the first and last names. Also, don't add them as array values. When it comes time to look up a value in there with in_array(), PHP will have to scan potentially the whole array to find a match. A faster method is to use array keys; put the whole $row as the value. Well, for starters, I don't see anything trying to use $names in there. Since you're going with the approach I said before about having the first and last names be the array key, you can use isset() to tell if there is an entry according to the name parts from $item.
-
Print image to receipt printer from PHP on Windows
requinix replied to siric's topic in PHP Coding Help
How does that work, exactly? Does the USB show up as a file device you can just copy files to? What does that process require you to do? -
Check what I said again. Your query on the database (1) needs to set up an array that holds all the records in it so you can look in there for a match easily, and therefore (2) it has to happen before the foreach.
-
Putting a database query into a loop is almost always a bad idea. Do one query ahead of time that looks up every record, then stuffs it into an array. You can use the firstname + lastname (that being the only unique (?) piece of information you can work with) as the array key, and for fun the entire row of data as the array value. Then your foreach loop checks that array for a match.
-
Removing the battery from a fire alarm does not make the fire go away.
-
Use number_format.
-
You're saying you can open a popup window, handle clicking on a radio button, and update the parent window's form data, using only HTML and CSS? I'd love to see that.
-
Format all dates in an array returned from PDO
requinix replied to mongoose00318's topic in PHP Coding Help
Yes. -
I'm sorry but it sounds like you're saying that your application is letting in bad data: invalid items in a non-member's shopping cart. That's the problem, isn't it? So how about fixing that problem?
-
Is there any particular need to have every step on different pages? The first couple about location, sure, but after that, wouldn't it be easier to have everything at once? It also helps the user see just how much they'll have to do, instead of one more page after one more page after one more page... If you need multiple pages, what about simulating multiple pages? Put everything into the one HTML response, then use Javascript to show/hide chunks of it as the user progresses. On that note, is there a need for this to be PHP at all? Javascript is quite capable of doing math. You may be able to do all of this on the client side.
-
Javascript to open the window, Javascript to handle the radio button selection event, then window.parent will give the popup's code a way to reach the parent window's form and textbox.
-
Short answer: it's safe. Longer answer: it's as safe as any other PHP file on your server. It's a common practice to put this script, or at least a script that defines variables/constants with database credentials, in a PHP file that is not located inside the web root (eg, outside of your public_html or www or whatever directory that your site is based in) because if it's not an actual page then it really shouldn't be in the root; this practice is easy to achieve when you get larger sites that have a single public_html/index.php that runs an "application" or some similar concept whose files are all outside the root.
- 1 reply
-
- 2
-