-
Posts
15,227 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Okay, now I'm done. $stmt->bind_param('s', $voucher_code_in_transaction); Where is the $voucher_code_in_transaction variable coming from?
-
This might be one of those times when you should step away from the computer for an hour or so, get something to eat, watch TV, and come back to the code with a fresh pair of eyes. As a reminder, this works: $stmt = $con->prepare('SELECT request_receiver_id, request_receiver_name FROM transactions WHERE voucher_code_in_transaction = ?'); $stmt->bind_param('s', $_POST['voucher_code_in_transaction']); and this does not work: $stmt = $con->prepare('SELECT voucher_value FROM voucher_codes WHERE voucher_code = ?'); $stmt->bind_param('s', $voucher_code_in_transaction);
-
Almost had my fun. This query works, right? $stmt = $con->prepare('SELECT request_receiver_id, request_receiver_name FROM transactions WHERE voucher_code_in_transaction = ?'); $stmt->bind_param('s', $_POST['voucher_code_in_transaction']); There's a big difference between the two of them.
-
I meant in the code. Good news: I've had my fun. $stmt = $con->prepare('SELECT voucher_value FROM voucher_codes WHERE voucher_code = ?'); $stmt->bind_param('s', $voucher_code_in_transaction); That query is not returning any results.
-
Good so far. How do you get the value of that voucher? Because if, for some reason, you didn't happen to have a value for it, you'd be adding 0 to the balance and total received, thus making it look like nothing happened...
-
Hint: It might not so much be that the query isn't working, but that the query is working except it's not actually changing the data...
-
This "<button type='button' onclick=\"javascript:'" + ZoomAndCenter(locations[i]) + isn't going to work. What it does is actually call the ZoomAndCenter function right at the moment that you're creating the button, when what you want is to have that function called when you click the button. As part of the onclick. Calling the function, which returns nothing, is why you see onclick="javascript:'undefined'" when you inspect the button. This code is rather old in its practices. Modern Javascript has you creating a button element like with document.createElement, attaching an event handler with addEventListener, then inserting the button into the document. That said, my preferred approach is to throw data attributes on a button and pull them out in the event handler. <button type="button" data-center-latitude="1.52986" data-center-longitude="110.36">Click me</button> I also still use jQuery because it's much easier than dealing with DOM stuff manually. $("#results button[data-center-latitude][data-center-longitude]").each(function() { const lat = parseFloat(this.dataset.centerLatitude); const lng = parseFloat(this.dataset.centerLongitude); const latlng = new google.maps.LatLng(lat, lng); new google.maps.Marker({ position: latlng, map, }); $(this).on("click", function() { map.setCenter(latlng); map.setZoom(15); }); });
-
Changing my report template with additional fields
requinix replied to keadeku's topic in Miscellaneous
It's going to be very, very hard for us to help you through this step by step if you don't have any PHP or development experience. It's like trying to cook some complicated dish in a kitchen and asking a chef to guide you through it - and the chef can't see what you're doing or even what dish you're trying to prepare. We can still try. However, first you should try to reach out to the original developers/company if you can. Let's start with a lot of details. What kind of software? What is this report? What about it doesn't work the way you want and how do you want to change it? What kind of fields do you want? Edit what parts of it? -
Why did you change the error log path at all? The php:apache image should have set everything up for you already.
-
What do you mean by "actionable"? My suggestion was, given you seem to like using YouTube, to find videos that can explain aspects of page design and not just simply about HTML and CSS syntax. The idea is that you could be able to look at the elements of a page and consider, say, whether they're using flexbox or grid, or how their arrangement changes when you resize your browser window. If your goal is really just to copy that site then use the browser developer tools to look at a site and see how they set it up, then see if you can replicate what they did (and without cheating by literally copying it).
-
Knowing the fundamentals of something is different from knowing how to apply them. That works for everything: speaking a language, driving a car, cooking a dinner... What you've learned is the fundamentals but perhaps not how you actually use them. That said, website design is another thing by itself that takes some amount of learning. Learning how to use paint and a brush doesn't mean you can sell a painting. If you're a video person then see if you can find videos about the designing side of websites, not so much the syntax side.
-
The / are part of the traditional syntax for it. They don't actually contribute anything to the regular expression itself, but they can be useful to separate the expression part from any flags you might want to apply. Since Javascript's RegExp separates the expression from the flags, and since it needs the expression as a string, there's no point in requiring the slashes. But if you write a regex literal, so not using the RegExp class directly, then you have to use the slashes because (a) that's the syntax so Javascript knows it's a regular expression and (b) you also have to specify flags at the same time and the slashes can separate them. /foo/i <=> RegExp("foo", "i") https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
-
what is the most secure random number generator function to use?
requinix replied to alexandre's topic in PHP Coding Help
Only a Sith deals in absolutes. There's a very basic principle to consider: cost versus benefit. The issue here is whether to invest some undetermined amount of effort into making sure a theoretical attack on your voucher codes isn't possible. The cost is moderately high and the benefit, assuming we're not talking about vouchers worth thousands or millions of dollars, is negligible. It's not worth worrying about. -
You did start a new topic. But given how it's very closely related to this one, and how you didn't really include any information besides "I TRIED /FRENCH/ AND IT ISN'T WORKING HALP", I figured I''d save everyone (including myself) the headache of having to pull some more teeth by just bringing everyone back in here.
-
what is the most secure random number generator function to use?
requinix replied to alexandre's topic in PHP Coding Help
It's not that simple. People can't simply look at a number X and say "oh, now the next number will by Y". What they do is generate tons and tons of X values, analyze the patterns, and then predict what the next few Ys could be. That kind of thing is just not something most developers have to worry about. It's the realm of governments and banks. -
what is the most secure random number generator function to use?
requinix replied to alexandre's topic in PHP Coding Help
rand() wasn't very good until PHP 7.1 when they made it be the same thing as mt_rand(). Is it cryptographically secure? No. Is that relevant to what 99.9% of people need it for, including you? Also no. Create an "alphabet" of the characters you want to support in the password, which I say because omitting ones like O/0 is reasonable, then write a simple for loop that creates a password of whatever length you want by drawing from that alphabet. Also, creating passwords like this is typically wrong. -
Merged. I lost track of whether this was pointed out, let alone resolved, but are your regular expression strings including the / delimiters too? Because they should not do that.
-
Probably? Consider that we have absolutely no idea who you are, what you're working with, or what kind of problem you're facing - except for what you tell us. Things like "news posts" and "header images" and "events banners" mean nothing to us unless you can describe what they are.
-
And I want a $500k/year job. What you and I have in common is that asking people on the internet to give us what we want isn't going to work. How about providing a lot of detail about whatever you're trying to do and including one or two specific questions with it?
-
I guess I'm saying you've got three solutions in this thread that all work, so if whatever you're doing isn't, you've got a different problem.
-
-
Take your pick. I think VS Code and PhpStorm are the top two right now.
-
Your query binds a parameter it doesn't use, you loop on whether it rows thus it'll either loop forever or not at all, and you're attempting to shuffle a number. I was hoping you would pay more attention to the part of my post where I said "likely the wrong solution" and less so on the "will not work as is".
-
Putting aside that your code will not work as it is, and that this is very likely the wrong solution for what you're trying to do, You're dealing with numbers up to 17 digits long. Unless you're generating millions of these, you're not realistically going to get a duplicate. Put it into a loop and it'll work.