-
Posts
4,704 -
Joined
-
Last visited
-
Days Won
179
Everything posted by kicken
-
Make youtube video play on click of image
kicken replied to webdeveloper123's topic in Javascript Help
The variable is undefined because of how variable scope works in JS. Variables are limited to the function they are defined in. Regardless, you shouldn't be typing that into the console, it should just be part of your script. -
Your code is simply not structured properly. Like I said above, you're only attempting to validating the username if it's empty. You should be doing the opposite, validating it if it's not empty. Even you made that change, the code would still fail because your code to save the results to the file would be in the else branch which would never run. What you need to do is re-structure the script to have your validation steps be independent and then check for overall success before saving the result. Something like: $errorList=[]; if (empty(trim($username))){ $errorList[]='Username is empty'; } else if (str_contains($username, ' ')){ $errorList[] = 'Username has a space'; } if (empty(trim($password))){ $errorList[] = 'Password is empty'; } if (count($errorList) === 0){ //No errors, do stuff }
-
You are only checking the username for spaces/invalid characters if it's empty. If it's empty, then by definition it'll have no spaces or invalid characters.
-
Make youtube video play on click of image
kicken replied to webdeveloper123's topic in Javascript Help
You are referencing elements before they exist (since they come after the <script> in your document. What you should do is wait for the DOM to be fully parsed before you start trying to interact with it in your scripts. With jQuery, you accomplish that like so: jQuery(function($){ //Put your code here }); -
Make youtube video play on click of image
kicken replied to webdeveloper123's topic in Javascript Help
The constructor requires a configuration object. The instruction to type that into the browser console was just to verify the library loaded properly and the constructor exists. Now, you move on with the rest of the instructions in the README file. Step 5 gives you an example of how to implement it, with the config object. -
This is wrong. fopen returns a resource, but file_get_contents wants a filename. This should be triggering a warning and/or error for you (depending on PHP version), something like: if you cannot see that warning/error in your output or in PHP's error logs then you need to adjust your error reporting settings for your installation. If you want to use file_get_contents to read a file, then you don't fopen it first, you just call file_get_contents. $contents = file_get_contents('accounts.txt'); If you want to fopen the file (for example, so you can lock it) then you need to read the data using fread, fgets, stream_get_contents, or similar.
-
The code is the same as if one wrote .translate-div { display: inline-block; vertical-align: middle; } .logo-div { display: inline-block; vertical-align: middle; background-color: red; color: #fff; text-align: left; } Since both .logo-div and .translate-div have the same display and vertical-align styles, they were combined into a single block. The second block then has the styles that apply only to .logo-div. If block 3 specified the same property as block 2, then yes the block 3 value would be applied. Since both blocks specify different properties, there is no overriding necessary.
-
How to populate nested dynamic form inputs with data from server
kicken replied to PrashantS's topic in Javascript Help
try const $i = $(item).find('.i'); -
How to populate nested dynamic form inputs with data from server
kicken replied to PrashantS's topic in Javascript Help
Log both e and item. console.log(e, item); See if either of those will help you narrow down the selection to just the newly added row. -
The original data is JSON. If the " is actually part of the data and not a copy/paste issue here, then it's been run through htmlentities() or similar and you'll need to reverse that. If you're using a new enough version of mysql, you could potentially use json_extract to get the URLs. select json_extract(replace(jsonColumn, '"','"'), '$[*].imageurl') Otherwise, you'd probably just want to select the column, and parse and extract the data as you fetch results in your code.
-
You cannot nest forms. That should just be a single form tag with all the attributes, not separate. This will only be true if you have an input in your form with name="submit". Since you do not, it will never be true. A generic test for a form post is to test the request method. if ($_SERVER['REQUEST_METHOD']==='POST'){
-
How to populate nested dynamic form inputs with data from server
kicken replied to PrashantS's topic in Javascript Help
If the selects are getting cleared, then const $i = $(this).find('.i'); probably is selecting too many items. You can check how many inputs it's selecting by logging it. console.log($i.length, $i); If it's selecting too much, you'll need to either find a way to narrow the selection or save and restore the selected item when changing the option list. -
Something like if($gAgeEOY < $gYearToBeginIncomePayments[0]){ $gAnnualWithdrawalsBOY[0] = 0; } else if($gAgeEOY[0] == $gYearToBeginIncomePayments[0]){ $gAnnualWithdrawalsBOY[0] = 0.0*$gBenefitBaseBOY[0]; } else { $gAnnualWithdrawalsBOY[0] = max($gIncomeBenefit[0],0.0*$gBenefitBaseBOY[0]); } Note, double-equals (==) for comparison, and 0.0*$anything is 0, so your first two branches are effectively the same. instead of []. Here:
-
PHP is not excel. You can use PHP to accomplish the same tasks, but the syntax is different. For example, IF is a function in excel that looks like IF(condition, value-if-true, value-if-false) In PHP, if is an block statement and the syntax is like this: if (condition){ code_if_true } else { code_if_false } Inside each branch, you'd put whatever code you want to run, such as variable assignments. You cannot just put a value and try to assign it as a result, like this: $var = if (condition){ value_if_true } else { value_if_false } The above is invalid code and will not run. You have to have use separate assignment statements within each branch, like this: if (condition){ $var = value_if_true; } else { $var = value_if_false; } or if you have a simple conditional, you can use a ternary expression instead of a full if.
-
That's not even valid code. Your code in general is poorly formatted. You should put some time into trying to format it in a way that's more readable. You have $gPremium defined twice there as two different things. You have other instances of trying to use a variable as both an array and a scalar value which makes no sense. For example, $gYearToBeginIncomePayments is used as an integer in a for loop, then as an array later on in your malformed if statement. You're using {} instead of [] to access array elements in a couple places.
-
Return $this if static method called on an object
kicken replied to NotionCommotion's topic in PHP Coding Help
Static methods do not have a $this object, regardless of how they are called. To me, what you're asking for doesn't really make sense to do either. In your example code, I'd just make your echo / syslog function return void. -
If you want to pick and choose which characters can be used, you'll have to go through the unicode character list, decide what you do and don't want, then probably write your own filtering code for that. I dunno about you, but to me that seems like a lot of work for very little or no benefit.
-
How to populate nested dynamic form inputs with data from server
kicken replied to PrashantS's topic in Javascript Help
Use the browser's dev tools (networking tab) to inspect the URL and response of your ajax request. If the URL has the correct ID, but it's response includes all students then there is a problem in your PHP code somewhere. You'll have to start debugging that to determine why the ID filter is not being applied. -
That URL is redirecting to a registration page, and I'm not going to register to help fix a bug. If you still want to provide a URL but not have to mess with the setup much, my suggestion would be to just save the output of your script into a static .html file somewhere. As long as it's loading the same stylesheets and showing the same issue, it's enough to help. When the problem is fixed you can simply remove that file. Alternatively, try and re-create the issue in jsfiddle and provide a link to that.
-
Since we can't see whatever these core styles are, there nothing else really to say other than what you posted so far works fine. You need to post more details about the code and styles being used to get more help. If there is a URL to your page we could visit, that be best, otherwise provide the relevant styles and maybe a screenshot of the browser's dev tools when inspecting the span. A table is the correct thing to use when you have a table of data, which it seems like you do.
-
You have padding set twice, you should delete one of them. Otherwise, it seems to work fine if I copy/paste it into a jsfiddle test. Use your browsers developer tools to inspect the element, it should tell you what styles are applied, and if some aren't, why.
-
Dynamically accessing html value within the same file
kicken replied to PaulosK's topic in PHP Coding Help
Why? Your current JS code essentially just gets the SID using an input text field, just in a prompt() window instead of the page. There's really no effective difference. If this is just some placeholder for whatever you want to do with your RPi, maybe expanding on that would be good. The only way I imagine grabbing a value with JS from a RPi would be via an AJAX request. All in all, I'm confused and don't really understand what you're trying to do or why? You say As mentioned, the typical way to accomplish that would just be a simple html form without any JS complexity behind it. The warning you mentioned is probably from trying to run the form processing code without having submitted the form. If you're using the same page to display and process the form, your form processing code needs to only run when the form is submitted, not during the initial page load. This is typically done with something like: if ($_SERVER['REQUEST_METHOD'] === 'POST'){ //Form processing code here } -
Call to undefined function CommonMark\Parse()
kicken replied to rick645's topic in PHP Installation and Configuration
Sometimes you can make uninstall, but I don't know if that is standard. You might just have to go through and delete things manually. It's been a long time since I've built and installed anything like that, mostly I can just use apt to get whatever I need and let it manage everything. -
How to populate nested dynamic form inputs with data from server
kicken replied to PrashantS's topic in Javascript Help
Your URL is probably wrong. Seems like you tried to mix PHP style and JS style concatenation there. As such, you're PHP script probably isn't getting the correct ID and just loading everything.