php

Editing System Files With Elevated Permissions and PHP

I am attempting to create a very simple web interface for changing some system settings on a network appliance. I am fairly new to PHP and becoming painfully aware of how easy it is to do things in hacky ways, so I am trying to write everything with the best practices in mind. That said, what would the best practice be for editing files...

How to make Dynamic Website High Scalable?

Hey How can we make a dynamic website or a website which is developed in PHP and backend as MySQL a Social Networking Site High Scalable? ...

A tool to debug and test mod_rewrite (.htaccess) directives

Although being a decent web developer, I and most of my colleagues always struggle with basic tasks when using mod_rewrite. I read the manuals and understood most of it, however most skills I've learned in life are by doing. The trouble is, there's no easy way to debug the configuration. Most of the time if I succeed at configuring the...

Loop through two dimensional array with Smarty

Hey guys, I am trying to make the following loop work. Basically, I am trying to display the children as options. Why doesn't it work? The optiongroups are being displayed. And the arrays are constructed the right way. {foreach from=$tpl_parents item='row' key='i'} <optgroup label="{$row.NAME}"> {foreach from=$tpl_children....

Exotic names for methods, constants, variables and fields - Bug or Feature?

Hi, after some confusion in the comments to Is it safe to have 1 letter class names in PHP, e.g A, B, C I thought I make into a question. According to the PHP manual, a valid class name should match against [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*. But apparently, this is not enforced, nor does it apply for anything else: define('π'...

mysql functions in PHP functions.

For example: <? function getTitle(){ $query="SELECT title FROM news WHERE author = 'admin' LIMIT 5"; $result = mysql_query($query, $mysql_connection); $data = mysql_fetch_array($result,MYSQL_ASSOC); return $data['title']; } ?> And every time I want to submit a MySql query I must always include config.php inside the fu...

PHP will echo $_POST data, but won't let me store it

Okay, weird problem. I have the following php code: <?php $identifier = $_POST['DEPT']; function displaydata(){ return $identifier; } ?> HTML CODE HERE <?php echo displaydata(); ?> This results in a blank page. However, when I replace function displaydata(){ return $identifier; } with function displaydata(){ return $_P...

display duplicate record

I have a table called problemTBL, which contains the fields below problem_id Autoincrement,Pk passenger_id, accept duplicate values problem_name, problem description These are sample records: Problem_id passenger_id problem_name 1 22 NO Air condition 2 22 Dirty Seats 3 24 ...

Set minimum value of MySQL field - possible?

Quick newbie MySQL question. What would be the simplest way to ensure that the minimum value of a given field is 0? Basically, we have a script that runs automatically and subtracts an integer value from the value of a field every 15 minutes--but we want any entry that gets to 0 to stay at 0 and not go negative. This could be simply d...

Regexp for parsing words from sentence

I need a regular expression to parse words from a sentence or a paragraph. Some separaters that should be used are: spaces, and dots. So in: My name is Bob.I'm 104 yrs old. Bob and I'm are seperated even though there isn't any space between them, but a dot. Any other regular seperaters of words should also be included. ...

Cron job to put files on server

Let me start by saying that I know nothing about Cron, so sorry. How can I make a php or perl script get files from my computer and upload them to my web server everyday at midnight? The webserver is linux. The computer from which the files need to be retrieved is Windows. ...

[MAGENTO] Force customer to fullfill the address form again

Hi! I created a new attribute to the address form and it is working fine, my problem is with older customers. How can I make force them to have to edit their address? WHen they go to the checkout page, they choose the old address without knowing about the new attribute, and it is really important for us that they fill it properly any ...

How to select unique arrays from MySQL table row?

I have a table with 20 rows and one row have for example: 2,3,5,6,8,22 2,3,5,6,8,22,44,55 etc. How can I select from mysql table rows only unique numbers, not duplicated so results are: 2,3,5,6,8,22,44,55 The table definition: CREATE TABLE IF NOT EXISTS `test` ( `id` int(11) NOT NULL auto_increment, `active` tinyint(1) NOT N...

PHP parse error

Hello, firstof all, i excuse in advance, this error may be a simple one. But i slept like 4 hour this night... :'( <?php echo url_for('@news_read/id=?'.$news_item->getId()) ?> outputs a syntax error and i don't see where it is (i wouldn't see an elephant right now...) Thank you ...

How can I improve this php code

Hi, I have a txt file that gets loaded and printed using a class. I'm relatively new to php, so I wonder if the class can be improved and some of the duplicated code (when printing the change-log) can be removed. Here is the class : class changesHandle { public function load($theFile, $beginPos, $doubleCheck) { // Open f...

Using Curl for load time testing PHP

Using PHP if I load the URL http://www.cars.com with Curl then use curl_getinfo() to find the total time it takes to load... Will it calculate the load time including all images, and anything else displayed on the page. Or just the HTML (or whatever) file that is located at http://www.cars.com ? curl_getinfo($ch, CURLINFO_TOTAL_TIME); ...

Find by filename rather than ID in data mapper class

I have an abstract data mapper class: <?php abstract class ADataMapper { abstract public function addNew($dataObj); abstract public function update($dataObj); abstract public function find($primaryKey); abstract public function delete($dataObj); } ?> In a sub-class of ADataMapper, I need to find a row by a column that ...

load .swf file quickly at client side !!!

Any tips or methods(encryption, plugins etc) to load flash files (i.e. swf) as quickly as possible at the client side ??? consider files size is between 5MB - 10MB.... ...

PHP form to excel mailer

While I do understand php, I'm more of a sysadmin than a programmer. Add that I really hate HTML and never used AJAX nor javascript :) I'll have to do a php page that gets data from an HTML form and sends it as an Excel attachment via email. Of course I'd like to reuse as much code as possible from already-made solutions. It's kind of "...

HTTP to HTTPS redirect not working on Apache with PHP

I have a script that handles several different redirects on a server with a snippet that looks like follows: if($url == "http://www.url.com") {header("Location: https://www.url.com/index.html");} The script works exactly as intended with one issue - all of the https redirects end up redirecting to http (versus the https as defined...