<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
var option_count = "text something";
$(document).ready(function(){
$('div').append('<?php echo add_option("' + option_count + '"); ?>');
});
</script>
<div></div>
<?php
ini_set('display_errors', 1);
function add_option($count) { ob_start();
echo $count;
$stuff = ob_get_contents();
ob_end_clean();
echo replace_newline($stuff);
}
function replace_newline($string) {
return trim((string)str_replace(array("\r", "\r\n", "\n", "\t"), ' ', $string));
}
?>
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Friday, 8 July 2016
How to Append Javascript/Jquery code run using PHP
Monday, 27 June 2016
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
Write following code into cross-origin's .htaccess file
Example:
Ex 2 .
in php file : header('Access-Control-Allow-Origin: *');
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
Example:
- You open "http://example.com" (here you see the cross-origin error of http://abc.com)
- Open .htaccess of abc.com and paste above code.
Ex 2 .
in php file : header('Access-Control-Allow-Origin: *');
Friday, 24 June 2016
How do I delete/reset unpushed commits on Git / Bitbucket
Delete the most recent commit, keeping the work you've done:
Delete the most recent commit, destroying the work you've done:
git reset --soft HEAD~1
Delete the most recent commit, destroying the work you've done:
git reset --hard HEAD~1
Tuesday, 14 June 2016
Sort by price, quantity low-> high. 0 price get last
Here is the my result query. I have required result of sort by price low-> high but it gives me a result that starts with records that have the price 0. This is correct, but I don't want the 0 price records first. Result should start with prices greater than 0 and 0 price records should be displayed last.
Please help me to solve my this query.
For example, the result should start start with price 12.00, 15.00..... 0, 0, 0
SELECT
product_id, quantity, price,
CASE price WHEN 0
THEN 1
ELSE 0
END
as is_price_zero
FROM
product
ORDER BY
is_price_zero ASC,
price ASC
Merging master branch from another sub branch in Github, Bitbucket
There are Two way for merge branch
First Way For Merge branch
Second Way For Merge branch
First Way For Merge branch
- Open Terminal.
- Change the current working directory to your local project.
- Check out the branch you wish to merge to. Usually, you will merge into master
- $ git checkout master
- Pull the desired branch from the upstream repository. This method will retain the commit history without modification.
- $ git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME
- If there are conflicts, resolve them. For more information, see "Resolving a merge conflict from the command line".
- Commit the merge.
- Review the changes and ensure they are satisfactory.
- Push the merge to your GitHub repository.
- $ git push origin master
Second Way For Merge branch
$ git checkout master
$ git pull origin master
$ git merge test
$ git push origin master
Monday, 6 June 2016
https%3A%2F%2F Forbidden You don't have permission to access in PHP, Codeigniter, .net
It seems like my shared host provider is detecting the presence of "http://www" or "http%3A%2F%2Fwww" in any get request and serving up a 403 page.
I also get an 'in addition' error..."Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
This only happens with this string. If I change it to something else the get is successfully submitted and the target page successfully returned.
If it helps I'm writing a QR code getter, so the ability to submit urls is quite important.
Also, strangely I can submit a url as long as it doesn't have 'www' in it. I can also submit 'www' as long as it isn't preceded by 'http://' (or the encoded version)
edit: Just to confirm this wasn't a specific problem with the page I was writing, I went to another page on my website that uses get request and manually inserted the string. This also generates the 403 error.
Answers
Request to remove this strange security feature or "ModSecurity" of your account from your provider (Hosting Provider).
Don't send urls with http://www in URL. For example replace https%3A%2F%2F to https:// before sending data PHP.
How to run URL Using exec, Shell_exec in php
function testf(){
$url = 'http://www.google.com';
$outputfile = "jems.html";
$cmd = "wget -q \"$url\" -O $outputfile";
exec($cmd);
echo file_get_contents($outputfile);
}
Subscribe to:
Posts (Atom)