-
Posts
15,266 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
Not that anyone has been using it this decade - or century, even - but there's a technology that exists which is designed for transforming XML into HTML as you just did. It's called XSLT. You can do it fully within PHP, but here's a demo without. kjv.xml <?xml version="1.0"?> <?xml-stylesheet href="kjv.xslt" type="text/xsl"?> <root> <book num="I don't know"> <chapter num="17"> <verse num="1">And after six days Jesus taketh Peter, James, and John his brother, and bringeth them up into an high mountain apart,</verse> <verse num="2">And was transfigured before them: and his face did shine as the sun, and his raiment was white as the light.</verse> <verse num="3">And, behold, there appeared unto them Moses and Elias talking with him.</verse> <verse num="4">Then answered Peter, and said unto Jesus, Lord, it is good for us to be here: if thou wilt, let us make here three tabernacles; one for thee, and one for Moses, and one for Elias.</verse> <verse num="5">While he yet spake, behold, a bright cloud overshadowed them: and behold a voice out of the cloud, which said, This is my beloved Son, in whom I am well pleased; hear ye him.</verse> <verse num="6">And when the disciples heard <i>it,</i> they fell on their face, and were sore afraid.</verse> <verse num="7">And Jesus came and touched them, and said, <span class="j">Arise, and be not afraid. </span></verse> <verse num="8">And when they had lifted up their eyes, they saw no man, save Jesus only.</verse> <verse num="9">And as they came down from the mountain, Jesus charged them, saying, <span class="j">Tell the vision to no man, until the Son of man be risen again from the dead. </span></verse> <verse num="10">And his disciples asked him, saying, Why then say the scribes that Elias must first come?</verse> <verse num="11">And Jesus answered and said unto them, <span class="j">Elias truly shall first come, and restore all things. </span></verse> <verse num="12"><span class="j">But I say unto you, That Elias is come already, and they knew him not, but have done unto him whatsoever they listed. Likewise shall also the Son of man suffer of them. </span></verse> <verse num="13">Then the disciples understood that he spake unto them of John the Baptist.</verse> <verse num="14">And when they were come to the multitude, there came to him a <i>certain</i> man, kneeling down to him, and saying,</verse> <verse num="15">Lord, have mercy on my son: for he is lunatick, and sore vexed: for ofttimes he falleth into the fire, and oft into the water.</verse> <verse num="16">And I brought him to thy disciples, and they could not cure him.</verse> <verse num="17">Then Jesus answered and said, <span class="j">O faithless and perverse generation, how long shall I be with you? how long shall I suffer you? bring him hither to me. </span></verse> </chapter> </book> </root> kjv.xslt <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" /> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="/root/book" /> </body> </html> </xsl:template> <xsl:template match="book"> <h1>Book <xsl:value-of select="@num" /></h1> <xsl:apply-templates select="chapter" /> </xsl:template> <xsl:template match="chapter"> <h2>Chapter <xsl:value-of select="@num" /></h2> <ol start="{verse[1]/@num}"> <xsl:apply-templates select="verse" /> </ol> </xsl:template> <xsl:template match="verse"> <li><xsl:apply-templates /></li> </xsl:template> <xsl:template match="b | i | span"> <xsl:copy-of select="." /> </xsl:template> </xsl:stylesheet> In a browser, which you might have to run through a webserver depending on your browser security settings, (you can see the italics in verses 6 and 14; the spans are invisible but they are present)
-
Choices.js cannot "re"setValue() via ajax
requinix replied to amirelgohary1990's topic in Javascript Help
Your setChoices creates a new Choices object every time. Evidently the API doesn't like that. You need to create your Choices just once, such as in its own variable (defined outside the function). Feel like you've got some slightly larger issues with design here, though...- 1 reply
-
- javascrip
- choices.js
-
(and 2 more)
Tagged with:
-
Reconcile what? If you output the message before the pause then you see the message before the pause, and if you output the message after the pause then you see the message after the pause...
-
Find the difference between two dates in non-standard format, mysql
requinix replied to oslon's topic in MySQL Help
...What are you using to view the CSV file? edit: Nevermind, looks like it does use a localized format after all. Stupid Jira. For PHP, use date_parse_from_format() or DateTime's createFromFormat, using the "d/M/y h:i a" format. https://3v4l.org/NPZvF -
Find the difference between two dates in non-standard format, mysql
requinix replied to oslon's topic in MySQL Help
Step 1: stop storing them in a non-standard format and use DATETIMEs instead. There is no step 2. Seriously. Use a standard format and this problem, and very likely other problems you've had or are yet to have, will go away. -
disable xdebug without uninstall
requinix replied to rick645's topic in PHP Installation and Configuration
Yes: xdebug.mode = off. -
disable xdebug without uninstall
requinix replied to rick645's topic in PHP Installation and Configuration
If you don't want to use the extension then don't install it 😕 -
disable xdebug without uninstall
requinix replied to rick645's topic in PHP Installation and Configuration
The extension still gets loaded and functions will still exist. Changing the xdebug.mode merely tells Xdebug not to do anything. https://xdebug.org/docs/all_settings#mode -
Well, look at the difference between the two (besides the IfModule). Before you had RewriteRule ^(.*)$ profile.php?$1 [L,QSA] That would turn "johndoe" into "profile.php?johndoe". That's not what you wanted. Now you have RewriteRule (.*) /profile.php?id=$1 [L] That will produce "profile.php?id=johndoe". Keep in mind this will kick in for any path that doesn't exist - not just "words". You should consider limiting exactly what this can match.
-
PHP is the cart, your web server is the horse. You cannot put the cart before the horse. Pick the simplest .htaccess you've tried and post it here, then we'll see what's wrong with it. Can I also assume that you, at some point during these 500 errors, looked in your server's error logs for an error message? What did it say?
-
You can, of course, change that.
-
PHP mail() w/pdf attachment showing as text?
requinix replied to Rayj2019's topic in PHP Coding Help
The point of a library like PHPMailer isn't so that you don't know what's going on. It's so that you don't have to worry about details - as you put it, so you can "get this to work". Because here are the lines where you're doing something wrong: $eol = PHP_EOL; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\""; $header .= "--".$uid.$eol; $header .= "Content-type:text/plain; charset=iso-8859-1.".$eol; $header .= "Content-Transfer-Encoding: 8bit".$eol.$eol; $message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol; But it's sure not obvious what's wrong about them, right? Switch to PHPMailer or SwiftMailer or some other standard library so you can get this problem resolved quickly and move onto the next one. -
It's not clear exactly what some paths are here. On your computer, does http://localhost/assets work? Does your-website.com/assets work? And I'm not sure what "private_html" is. Do you mean "public_html"?
-
No, but you also didn't post the full code. Most likely culprit is going to be a change in the PHP configuration. Have you checked your server error logs yet?
-
How do you "call" them? What's the rest of the code? Is script.js meant to directly manipulate index.html or is it a utility thing and index.html has its own Javascript code? Is your question about how to get those values into index.html or is it how to get those values into the HTML itself?
-
"Absolute address" is just you explicitly telling the browser what you want instead of letting it fill in the blanks itself. There's no difference between an absolute URL and a relative URL if they're both referring to the same resource.
-
htaccess/htpasswd stuff works as part of the HTTP protocol, much like cookies. Same-domain AJAX shouldn't know or care that it's happening.
-
How simple and how user-friendly do you want it? You can configure your web server to do authentication with a simple list of usernames and passwords, but it's not a fancy solution: you have to manage the list yourself, and the authentication prompt is very plain. The username is available to PHP, if you want to do something with it after the authentication happens.
-
Looking closer, 1. You only use a #MessageContainerFoot for info-level messages. 2. You repeat that for every info message, which means you'll potentially use the same "MessageContainerFoot" ID for more than one element, which is wrong. Think about exactly what you want to do, then check your code from top to bottom to make sure that it is working the way you wanted it to. Because there's clearly some disconnect between "put #MessageContainerFoot into #MessageContainerHead" and "only use #MessageContainerFoot for info messages".
-
Have you checked for Javascript errors? Are you sure your initial function is running? Is it possible the element did move after all and it's just not displaying how you expect it to? You have a process for doing the work. Check it, step by step, to find out where it stops working.
-
That answer also got shut down I gave up and found the answer somewhere else and there is no trickery in the question after all. Nested hints:
-
Experiencing problems with CODE tags
requinix replied to Yesideez's topic in PHPFreaks.com Website Feedback
^ That. Once you submit your post, the forum will do a little light processing on it, and that will screw around with whitespace. Those Code blocks also provide some simple syntax highlighting, provided you pick the right language, so please do use them. -
Nope, a decimal point counts as an operator (apparently). Supposedly it really is just the problem at face value: those four numbers, each used once, and as many add/subtract/multiply/divide operations (and parentheses) as you want. The way that latter point is phrased is unusual. "Unlimited supply", but you'd only ever need three... So you'd think there's a trick there, but it specifically states you have to use them as binary operators.
-
Could swear I had a book with these sorts of puzzles but I can't find it. So I'm looking through the internet for a good source to post - not original, but it is something - and I find this one: I can't solve it. Even ran a quick script to try every possible combination of ((# _ #) _ #) _ # and nothing works. So I'm figuring there must be some trick in the phrasing, except I'm not seeing a loophole in there: "each number exactly once" using the "binary operations" of "addition, subtraction, multiplication, and division". (And in fact, creating operators like negation and exponent still isn't enough to get a solution.) Non-answer: if the goal is to be legally an adult then coming up with 22 would be fine too.
-
If you're not running this in Docker, or perhaps even if you are, it sounds like your database configuration wasn't set up properly. Check the hostname you have it using.