php

What are your Common Magento Configuration Mistakes?

If there's something that everybody hates about Magento it's endlessly configuring your modules before being able to write some code. I'm trying to collect a list of common Magento configuration errors for a future project that's I'm close to launching. I'm looking for specific examples of things like using the wrong naming conventio...

Specific ordering of records based on list of IDs? with MySQL & PHP

I have a 'user' table in MySQL When users login to my app, they can see a list of all other users and via some javascript-drag-drop can arrange which order the other users appear in. We want to save that order. And it is saved to their record (i.e. 'order_pref' = 4,3,5,23... list of user_ids in the order they specified). So that's fin...

Enter ID instead of name on submit (form)

In my users_subjects table, I have a user ID and a subject ID. When a user (of admin level) creates a subject they select from a drop down menu a project. Here is the select query to draw up appropriate values: $sql = "SELECT users_subjects.users_subjectsid, subjects.subjectn FROM subjects JOIN users_subjects on subjects.subjectid = us...

MySQL: Which is faster — INSTR or LIKE?

If your goal is to test if a string exists in a MySQL column (of type 'varchar', 'text', 'blob', etc) which of the following is faster / more efficient / better to use, and why? Or, is there some other method that tops either of these? INSTR( columnname, 'mystring' ) > 0 vs columnname LIKE '%mystring%' ...

How to install Eclipse + PHP Development Tools (PDT) + Debugger on Mac in The Year 2010

I had a lot of trouble installing Eclipse and PDT on my system. It took two days, largely because all the tutorials I could find were out of date (written in 2008, it's 2010 now) and various steps they included were no longer necessary, broken, or irrelevant. I wanted to write my process here so it could be improved upon (via wiki) as ti...

Access Controller data from an element

I have an element for my side bar navigation being called from my layouts/default.ctp file, I need to access some data about categories from my Photos controller. How would I go about doing this? ...

CSS not rendering on MAMP

I'm working on a Wordpress blog. I'm embedding a stylesheet as follows: <link rel=”stylesheet” href="<?php bloginfo("stylesheet_url"); ?>" type=”text/css” media=”screen” /> However, the CSS doesn't render, at all. I've checked that the URL that is being put in the href is correct. The CSS is found. But, it doesn't render, in all brows...

304 Not Modified issue

Sorry for the probably wrong title. I am writing some code to handle If-Modified-Since and If-None-Match requests as part of caching. Everything works perfect except for that PHP returns some content (an empty line) after the headers. The page content should be empty instead. The code that I am using is: <?php $lastmod = filemtime($f); ...

PHP: How do I get the string indexes of a preg_match_all?

Hi all, let's say I have two regexp's, /eat (apple|pear)/ /I like/ and text "I like to eat apples on a rainy day, but on sunny days, I like to eat pears." What I want is to get the following indexes with preg_match: match: 0,5 (I like) match: 10,19 (eat apples) match: 57,62 (I like) match: 67,75 (eat pears) Is there any way to ...

Is a server side script necessary to process a form?

Is a server side script necessary to send a form to email? For example, suppose I want to submit this form. Is it only possible with php asp.net etc. or it can be done with javascript only? <HTML> <HEAD> <TITLE>HTML form tutorial example</TITLE> </HEAD> <BODY> <H1>HTML form tutorial example</H1> <FORM> Name...

calculating and showing a date as 'secs ago', 'mins ago', 'hours ago' etc

I've got a small custom made blog type thing and want to display the date posted next to comments. I'd like to do it in the format of: posted 23 secs ago posted 43mins ago posted 1hr ago posted 1day ago posted 2 weeks ago ... probably won't get much longer than that because articles older than a month aren't shown. I can stored the a...

Formatting numbers by tokens with php

I'm looking for a way to format numbers using "tokens". This needs to be conditional (for the first few leading characters). Example: <?php $styles=array('04## ### ###','0# #### ####','13# ###','1800 ### ###'); format_number(0412345678); /*should return '0412 345 678'*/ format_number(0812345678); /*should return '08 1234 5678'*/ fo...

PHP Watermarking - Zubrag

I'm using zubrags PHP watermarking script (attached below) and it works great except when I try and use a PNG-24 as my watermark. The resulting image has a garbled, non-transparent watermark. I'm wondering if anyone could help explain what I would need to alter in the script below so that a PNG-24 embeds as a proper watermark on the im...

Read a value from JSON using PHP

Hi guys, Im new to JSON and php. I need to grab the lat and lng from the following json after calling json_decode(). But I don't know how to access them. { "status": "OK", "results": [ { "types": [ "street_address" ], "formatted_address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA", "address_components": [ {...

Getting random record from database with group by

Hello i have a question on picking random entries from a database. I have 4 tables, products, bids and autobids, and users. Products ------- id 20,21,22,23,24(prime_key) price........... etc........... users ------- id(prim_key) name user1,user2,user3 etc bids ------- product_id user_id created autobids -------- u...

how to submit a from with validation in PHP?

I want to submit this form through PHP. with validation for required field and validation for phone number and email field also <form action="" method="" id="get-protected"> <div class="row requiredRow"> <label for="txt_FirstName"> First Name</label> <input id="txt_FirstName" type="text" class="required" title="First Nam...

What is wrong with this SQL query? (or perhaps why doesn't MySQL like the sixth field?)

Here is my table: id int(11) name varchar(255) description text highest_bidder int(11) value varchar(255) group int(11) I originally didn't have the group field in there but added it later. Anyway, I go to insert into the database using the following snippet: INSERT INTO ...

Creating pdf file using php

Hi all, Can someone suggest me which tutorial I can follow to get thorough knowledge about creating pdf files using php? Thanks ...

Alternative for PHPlivedocx?

Hello, Is there any other free alternatives to PHPliveDocx? I would like to create a Word document based on templates and user inputted data. The template will resides on the server and the client(online or c# windows application) will be used to collect user input. Once data has been collected, server-side script(PHP) will be used...

the coding problem in server

$fp = fopen("http://feeds.reuters.com/Reuters/PoliticsNews?format=xml","r") or die("Error reading RSS data."); The above coding working correctly in localhost;;; but in server display "Error reading RSS data."... i dont know why.... anybody please explain me... i am waiting... thanks ...