php

PHP / Apache issue with pound signs (£)

I have some text stored in MySQL database like this "Tom gave Sarah £5 for her book". Up until last Monday this displayed on the site perfectly when pulled from the site, showing "Tom gave Sarah £5 for her book". Now, even though I have not changed/installed/uninstalled/updated anything at all, it has stopped working. The old values in...

Strange delay POSTing from php fsockopen

Hi all, I'm working with the following section of php code. The purpose is to POST an image file from one server to another. This works perfectly and very quickly as long as the file is < ~250k. Much over 250k, and the process time jumps to ~60 seconds, and increases from there with image size. Any ideas? Thanks! John $fileContents ...

PHP String Parsing

Hi! I have string which contains something about "amount 3 val 6, amount 7 val 8" and so, what regular expression should I use to get array with corresponding amounts and values? ...

How to get user's Java version using PHP?

Is there a simplistic solution to obtain the version of Java running on a user's workstation using php? Basically I want to know the version of Java running on a user's machine who accesses my portal. This data will help me make some policy decisions later since our product is Java based. ...

Is there a list like operator in javascript?

I'm now implement such a task:I need to convert PHP variables to javascript $arr['name1'] = 'value1'; $arr['name2'] = 'value2'; so that after processing,should be: <script type="text/javascript"> var name1 = 'value1'; var name2 = 'value2'; ... I hoped to do it this way: <script> list(<?php echo join(',',array_keys($arr)?>) = <?php...

How would I perform math within a sql query to calculate percent difference?

I would like to take surveys (2 or more choices), and place the results in a table. I just want to know how I would tally up the results in a sql query. Even more, should i be doing the math within the query, or just use PHP to do the math? Example Questions Table question_id (int) question (text) answer_1 (varchar) answer_2 (varchar...

Not Another Parse-HTML-With-Regex Question

Hello, I've read a few questions on here re parsing HTML with regex, and I understand that this is, on the whole, a terrible idea. Having said this, I have a very specific problem that I think Regex might be the answer to. I've been fumbling around trying to work out the answer but I'm new (today) to Regex, and I was hoping some kind ...

Variable CURL Response Time

All, I have a PHP CURL request to an HTTPS site which takes a JSON and request and returns a JSON response. Usually it should not take more than 1 second. But, I have seen that the CURL response time is variable. Sometimes, it takes 4 seconds to respond and sometimes 1.2 seconds. Why is this so and How can I make it faster and process t...

Can PHP script terminate even if set_time_limit(0) is set?

I am trying to track down what appears to be a very strange bug. I have an application that is structured roughly as follows: set_time_limit(0); register_shutdown_function('logScriptCompletion'); function logScriptCompletion() { log('script completed'); } log('script started'); // do some calculations periodically printing out pr...

PHP exec() call never runs

I believe this is a permissions issue, but not sure how to fix it. I have a php script -- mainscript.php -- that calls: $scriptCall = "/usr/bin/php wrap_prep.php 2>&1 &"; When running mainscript.php, the wrap_prep.php never executes. However, when I log into my webserver as root and run php wrap_prep.php 2>&1 & it works fine. I ha...

Codeigniter/PHP delete row after period of time...

Is it possible to delete a SQL db row after a period of time? ie. I have a row that has an expiration date and it needs to be deleted on that day? If I'm displaying info to a user, is it better practice to just hide "expired" entries and keep the data? ...

Php: creating functions in a for () loop

Does anybody know how I could write a function, that was able to create other functions, using the contents of a variable for it's name? Here's a basic example of what I'm talking about in php: function nodefunctioncreator() { for ($i =1, $i < 10, $i++) { $newfunctionname = "Node".$i; function $newfunctionname()...

How to I inject only certain parts of PHP page using PHP

I'm a total beginner when it comes to PHP, so bare with me. I know I can include other files using PHP <?php include("file.php"); ?> Now my question is how do I inject only certain parts of "file.php"? Lets say I have some header code and some footer code within file.php. How do I organize file.php with the correct separated sectio...

Difference between Model and Model Resouce

Hey guys, Im starting a project with Magento. Let me first say, that i come from the MS world, i have never used PHP before, and while im catching up quite rapidly i'm def a php newb. I can't quite seem to grasp the differences between the model, resource model, resource and entity objects and how they are related in the magento archit...

php session does not destroy on refresh

i am making a 10 question survey with one question at a point. i made a session for passing values between questions. the thing i discovered is that the session values do not get destroyed even on a page refresh. is there a workaround or am i doing something wrong. just to make things clear, here is the code: session_start(); // $_SE...

How can I uses sessions if register_globals is set to off?

Because of security reasons, register_globals is set to off. And that sucks, because right now I could really have use of sessions. How do you guys solve this "problem"? UPDATE I have tried using $_SESSION, but it's not working. That's why I thought it had something to do with register_globals being off. In my header file, I have the...

Contollers and Views - MVC in Zend Framework

I am using MVC in PHP based Zend Framework. This is more of a design question. I have a controller that has a couple of actions. These actions are accessed via AJAX from the controller's view. The controller's actions, perform Business logic by accessing data from functions inside a model, and construct or echo HTML. This HTML is spit ba...

How to encrypt a string in Python and decrypt that same string in PHP?

I have a string that I would like to encrypt in Python, store it as a cookie, then in a PHP file I'd like to retrieve that cookie, and decrypt it in PHP. How would I go about doing this? I appreciate the fast responses. All cookie talk aside, lets just say I want to encrypt a string in Python and then decrypt a string in PHP. Are th...

codeigniter array variable

Here is my code so far, it all works except when I try to make 'company' = $company there's something im missing, and id love to know what if($query) // if the user's credentials validated/// { $this->db->where('username'); $this->db->select('company'); $company = $this->db->get('user'); $data = arra...

php page redirect

can php make a redirect call after executing a function? i am creating a function on the completion of which i want it to redirect to a file located in the same root folder. can it be done? if { //i am using echo here } else if ($_SESSION['qnum'] > 10) { session_destroy(); echo "Some error occured."; ...