php

Is there a tool to translate matlab to PHP automatically?

Especially I want to translate this answer in matlab to PHP, is it viable? ...

how to embed php with flex

I want to make a software in which few part of interface should be displayed in php and few part in flex then how i should do this ...

PHP sorting issue with simpleXML

test.xml: <?xml version="1.0"?> <props> <prop> <state statename="Mississippi"> <info> <code>a1</code> <location>Jackson</location> </info> <info> <code>d2</code> <location>Gulfport</location> </info> <info> <code>g6</code> <location>Hattiesburg</location> </info> </...

Requesting a website by client side script = Cross Side Scripting Hack. But requesting a website by server side script is not a hack! Why?

Generally, when we want to show the contents of some web page in the same page, we go for ajax requests. If say, I request to a web page in different domain with AJAX, it is not allowed because of the Cross side scripting error. But why is it allowed to access via a server side page. For e.g. we can use CURL in php to access any site.? W...

Which PHP image processing library is more powerful,imagick or gd?

And the reason? ...

PHP: Profiling code and strict environment ~ Improving my coding

I would like to update my local working environment to be stricter in an effort to improve my code. I know that my code is okay, but as with most things there is always room for improvement. I use XAMPP on my local machine, for simplicities sake Apache Friends XAMPP (Basic Package) version 1.7.2 So I've updated my php.ini : error_report...

How to do caching in php

I used the following code, but it is taking time. i want to cache without storing in a text file. $file = 'cache_toppers.txt'; if (file_exists($file) && filemtime($file) > (time() - $expire)) { $records = unserialize(file_get_contents($file)); } else { include("kalvidbconnect.php"); $query = "SELECT * FROM vpfmsttoppers"...

Array of previous weeks

Hello, I am trying to create an array of weeks for users to select to view stats week on week. What I'm looking for is an array that has the timestamp of week start (monday 00.00 to sunday 11.59) that I can then use in MYSQL queries. Has anyone got an code that might assist? I was thinking of doing something like: EDIT, Thanks to the ...

PHP chmod reports success when it has not worked - why?

Hello all, I have tried this: echo substr(sprintf('%o', fileperms($mdbFilename)), -4).'<br />'; echo chmod($mdbFilename, 0777); echo substr(sprintf('%o', fileperms($mdbFilename)), -4).'<br />'; The out put I get for the above is: 0666 1 0666 So the above has not worked! Why is this the case? And why does chmod report true? The va...

Site URLs using a PHP "pretty url" framework

I have been experimenting with the lightweight NiceDog PHP routing framework, which routes like this: R('entries/(?<id>\d+)') ->controller('Entries_Controller') ->action('show') ->on('GET') Now the .htaccess file is set up to do this redirect like so: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FI...

Session lost after page redirect in php

When I use php header redirection all session variables are lost... Some people say that adding exit(); just after the header(""); will solve the problem but it doesn't seem to be the solution... Can anyone please help? Here is how I store variable into the session: include 'dbc.php'; $err = array(); foreach($_GET as $key => $value)...

Display username to logged in user only?

I have a Wordpress blog set up to display comments as "Anonymous User" by hard coding it into the comments.php file. I would like to have it say the user's Username next to their comment and ONLY display that Username to THEM. In other words, if they're a guest, they'll see "Anonymous User" and if they're a registered/logged in DIFFERE...

How to automatically select the selected item in list menu after submitting the form?

Hi I have this code : <form id="form2" name="form2" method="post" action=""> <table dir="ltr" width="554" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="269" class="da"><div align="center"><span id="spryselect1"> <select onchange="form2.submit()" name="mpage" id="mpage">...

php shell_exec executing java program

In PHP code I try to execute Java program using shell_exec but I get empty line. When I tried to execute program in bash: #bin/bash echo "aaa" I get "aaa" but when i tried to execute the same file with #bin/bash java MainApp I got empty line This is the java code public class MainApp{ public static void main(String[] a...

How to retrieve & use the JSON response of website in PHP ?

I have to access the following url in my PHP code . https://test.httpapi.com/api/domains/available.json?auth-userid=0&amp;auth-password=password&amp;domain-name=domain&amp;tlds=com&amp;tlds=info&amp;tlds=org&amp;tlds=net&amp;suggest-alternative=true the above url returns a json response. My query is " how to retrieve the response in ph...

PHP htmlentities() on input before DB insert, instead of on output

Hi ! I wonder if there's any downside or bad practice in doing the following procedure: $user_input -> htmlentities($user_input) -> mysql_escape($user_input) -> insert $user_input into DB Select $user_input from DB -> echo $user_input instead of doing the following: $user_input -> mysql_escape($user_input) -> insert $user_input in...

Any procedural (non-OO) PHP Framework?

I've stumbled across a couple of PHP Framework questions on SO. But like //so/questions/2648/what-php-framework it's mostly an itching on the surface or popularity contest. Skimming through each frameworks API or introduction docs didn't give me a good overview either. However, I was wondering if there is something like a purely procedu...

Load Tracking Script on Form Submit

I'm trying to load a StatCounter tracking script after the form has been successfully sent. Here's the code: $.ajax({ type: "POST", url: "css/sendmail.php", data: dataString, success: function(data) { $('#script').load('css/script.html', function() ({ $('#overlay').css('visibility','hidden'); clearForm(); $('#...

Problem with mysql_query() ;Says resource expected .

I have this php file. The lines marked as bold are showing up the error :"mysql_query() expecets parameter 2 to be a resources. Well, the similar syntax on the line on which I have commented 'No error??' is working just fine. function checkAnswer($answerEntered,$quesId) { //This functions checks whether answer to question havi...

PHP How to access constant defined outside class?

I have defined some constants eg: define('DB_HOSTNAME', 'localhost', true); define('DB_USERNAME', 'root', true); define('DB_PASSWORD', 'root', true); define('DB_DATABASE', 'authtest', true); now when I try to do this: class Auth{ function AuthClass() { $this->db_link = mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die(mys...