Skip to content

Tag: php

How do you modify a file using JavaScript together with PHP?

I want to add text to a text document using JavaScript and PHP. What would be the best way to do this? Answer This is possible by using Javascript (front-end) to send an ajax request to the PHP server script that does the operation (back-end). What you can do is use jQuery.ajax or XMLHttpRequest. XMLHttpReque…

AJAX works on localhost, but doesn’t on live server

Below code works on localhost, but not on live server. MAIN EDIT: Only 1 thing remains which is not working: On AJAX success this will being executed: How ever, the label(for example) is not being updated. The label needs to be updated by the score which is given (data.score_result). Ajax code: When I put ale…

Why PHP strlen() and Javascript xxx.length is not equal?

I have following text: Ankylosaurus was an armored dinosaur that lived roughly 67 million years ago, at the very end of the Cretaceous Period. This genus was among the last of the non-avian dinosaurs, living alongside Tyrannosaurus, Triceratops, and Edmontosaurus. Its name means ‘fused lizard’; bo…

How do I return data as a Key & Value pair from MySQL

I’m trying to return a JSON object with a Key,Value pair, both of which are seperate columns in my MySQL table. So the MySQL table Looks (simplified 1000%) like this: And I want a JSON object like I could build it up as a string in MySQL by looping through the table and concat everything together, then …

Sweetalert2 redirection

I’m struggling with this for a few hours already and I think that the solution is very simple. First a bit of background. So, I have a php page where I can enter a number in a texfield. If the number entered is higher than the credit the user has, then I have to show an error message. When the