php

How to create a custom template system in PHP

Hello friend I want to use a custom template system in my php application, What I want is I want to keep away my php codes from design, I would like to use a tpl file for designs and a php file for php codes I dont want to use any ready maid scripts. Can any one point out some links link or useful info how to build a php templating...

image displaying issue

I have an image url but there is not image or the image name has been renamed, so i am not able to view the image in this case i want to show a default custom image. any idea on how to do it thanks in advance ...

How can I work out this view?

List -> l_user I have a List node that has a user-reference field (l_user). Story -> s-user I then have Story nodes that also have a user-reference field (s_user). There is no direct connection between List and Story. I want to add a view to List that lists all the stories that reference the same user that list references. Basically ...

PHP pagination problem, gives blank page

Below is a code for my pagination. The problem that I am having is that the page count is displayed correctly but when I click on page 2 onwards I just get a blank page. <?php if (isset($_POST['edit'])) { if (empty($_GET['page'])) { $page=0; } else {$page = (int)$_GET['page'...

PHP fails to complete a loop

I have a table with about 450,000 row. The table needs some derived fields updated. My loop is: $sql = "SELECT * FROM table_name"; if (!($r = @ mysql_query($sql, $db_connection))) die("Mysql query $sql . Error " . mysql_errno() . " : " . mysql_error()); while ($row = mysql_fetch_assoc($r)) { // do a number of calculations, wh...

Warning for header information in my test server but not in local why?

I have my site live in which i echoed few strings for testing, so it displayed me those test strings but along with the warning message Warning: Cannot modify header information - headers already sent by (output started at /home/companyfolder/public_html/mycart.php:117) in /home/companyfolder/public_html/includes/functions...

Get month of a given date

Get month of a given date which is stored in a PHP time variable in 'Y-m-d' format ...

My Memory Usage Assumption: Is it Correct?

I have a script when ran consumes 17mb of memory (logged using memory_get_peak_usage()). Script is ran 1 million times per day. Total daily memory consumption: 17 million mb 86400 seconds in a day. 17000000 / 86400 = 196.76 Assumption: Running this script 1 million times each day will require at least 196.76 dedicated memory. Is my ...

How can we calculate the HTTP request made by each web page of my website

can any one please help me to count how many HTTP request has to be made when i open my website Cricket News I am trying to increase the performance and better loading on all browsers. 1 more questions 1) How many Http Requests is better for better performance? ...

removing array from multidimensional array.

Hello i hav e a session that looks like this: array(3) { ["counter"]=> int(0) ["currentItem"]=> string(1) "2" ["addedToCart"]=> array(12) { [0]=> array(11) { ["aantal"]=> int(1) ["id"]=> string(1) "1" ["filmtitel"]=> string(11) "a_bugs_life" ["film_id"]=> string(1) "2" ...

Should I install Imagmagick over gd

I'm starting to work on a project that will require a lot of image manipulation. I remember getting the impression in the past that imagemagick was somehow better than GD. Since I have GD only, this will require me to install imagemagick, and I want to make sure it's worth the trouble. Can someone clarify if it's true that imagemagick ...

How to read image field from MSSQL with PHP

Hi Everyone, I am creating a web site that needs to synchronise an online MySQL database reading from the offline MSSQL server. All communication and reading all fields from MSSQL is working OK except that image field. I have been working with PHP and Mysql for some time and know how to insert/retrieve images to/from a MySQL database(us...

Calculating amount of months between dates

Hi, How would you go about calculating the amount of months between two arbitrary dates? Given that even if just one day falls on a month, it is considered a full month. Examples: 2010-01-01 - 2010-03-31 = three months 2010-06-15 - 2010-09-01 = four months Et cetera. I thought of just dividing the difference of timestamps with 2592...

problem in using CONCAT if the value is Null in mysql

hey guys i used CONCAT to get my tags and topics but if the story has no tag or topic then result is empty WHERE CONCAT( ' ', table_stories.tags, ' ' ) LIKE CONCAT( '%', table_tags.tid, '%' ) AND CONCAT( ' ', table_stories.associated, ' ' ) LIKE CONCAT( '%', table_topics.topicid, '%' ) as you see , ever...

How to insert date(y-m-d) into MySQL database ?

I have a field of type date in MySQL. When I try to insert any date in this field with PHP using following query, It stores 0000-00-00 in that field. For example: UPDATE test SET dob=2000-09-20 WHERE id=3 ...

Getting error in long running PHP script

Hi guys, As this is my first PHP web application so dont know mich about php configuration. Here is my case: I have developed an application in PHP/mysql, in which user can search his real followers. Now problem is that a user having say upto 2k followers and 500 real followers in that, does not give any error, but when i move to big ...

Best practice: Use same form for creation and update

Hi everyone, I'm just curious and was wondering how you guys handle it if you want to use the same html form and as far as possible the same php code to create and update an item. Example: On one page you can create a database entry with name, email address and age. On a different(?) page you see the form fields filled with your data a...

Gathering cookies

I'm not even sure how to describe what I'm trying to do since I don't know a whole lot about cookies, but here goes. Is it possible to use PHP to collect a cookie (or cookie file) from the browser cache, save it into the database, then clear the cache and re-save it back to where it used to be? What would be involved in implementing ...

Regex Rules for First and Second Character

Hello, I need help on following regular expression rules of javascript and php. JS var charFilter = new RegExp("^[A|B].+[^0123456789]$"); PHP if (!preg_match('/^[A|B].+[^0123456789]$/', $data_array['sample_textfield'])) { This regular expression is about First character must be start with A or B and last character must not inclu...

Zend Framework 1.10.7 telephone validator

Please See Correct Answer for solution to the requested question. Hi, Recently I have been searching for telephone validation in zend framework which I think is a missing component of their Validator framework. Therefore I created custom telephone validator which I would like to share with you. Put code below in a file accessible by...