php

PHP server on local machine?

Hello, I'm trying to build a php site and I'm wanting to test my php files without uploading them to my host. Basically testing them on my own machine before I upload them. This question has probably been asked a million times, but I can't seem to find a thread on it. Any help would be appreciated. Thanks in advance Rich ...

How to limit entries in ExpressionEngine?

How to make a counter in ExpressionEngine? {exp:weblog:entries weblog="news" limit="15"} {title} {body} Posted on {entry_date format="%M %d, %Y - %h:%i %A"} {/exp:weblog:entries} it seems 'limit' limits the SQL Calls , but not actual results.... Should i add php? more here: http://expressionengine.com/docs/modules/weblog/weblog%5F...

OO PHP question regarding arrays

Hi all, I'm trying to learn object oriented PHP by porting some of the simple exercises I've learnt in Java to PHP. This is one of them, to calculate the total salary of 3 people. I'm apparently having a problem with the array in the family class - php gives an error about "Undefined variable: a_family" on line 32. Could anybody point ...

how can I bust out of a PHP class initialization if the user isn't logged in?

I'm writing an admin section to a site using CodeIgniter. I am writing an Admin class that extends the Controller class, and then controllers for admin pages will extend Admin. I do this because I want the Admin class to check the user's session to make sure he is logged in -- and if not, to show the login page and abort initialization o...

Convert Python for -loop to PHP

How can you convert the following code to PHP? summat = [sum(arra[i:i+4]) for i in range(0,len(arra),4)] My attempt $summat = array() foreach ( range(0, $arra.length, 4) as $i) { $summat = array ( array_sum( array_slice( $array, $i, $i+5) ) ) // don't know how to append the sums the array ...

I want to use <pre></pre> to keep the format of input text, but the displayed text crosses the boundary of its parental tag<div></div>. How to solve this problem?

The text in <pre></pre> steps beyond the boundary of its parental <div></div>. How to solve this problem? It is said that the line lengths in the preformatted text can be shortened, but how to do it? I have seen <%# DataBinder.Eval(Container.DataItem, "Comments") .ToString().Replace("\n", "<br />") %> Is it c#? I am...

How to know php script is request in HTTPS not HTTP ?

I have checked all $_SERVER member var, still don't know how. ...

Submenus in Wordpress

I know you can create pages under a parent eg: -a --c --d --e -b --f --g But all of the themes I've looked at will only display the top menus. -a -b How can I create a menu with drop downs for the sub menus I'll handle the drop down scripting, but how do I access the page names in order to create one? ...

Reading content from Multiple Text Files

Looking for help in doing this: I have a directory full of text files that are named with a numerical ID. Each text file contains the body of a news article. Some news articles are segregated in different parts, so they are in different text files. The names are such 1001_1.txt, 1001_2.txt (These files contain two different pa...

PHP fwrite vs. output piping

I'm writing a tool that allows someone to connect to a web page and generate files for download on the fly. To write these files, I can use PHP functions like fopen or fwrite, or I could create a script that can be called as a system call to generate the output such as: php downloadGen.php > filetocreate.xml The fwrite version of the ...

PHP cURL: How do I make it visit this website before continuing?

I am passing post data to a website, but I have to visit the homepage first before I can navigate to any other parts of the website. So how can I do that? Do I just use a header redirect and then have it execute the rest of the cURL? Update: I think this might be better than the solution below: http://coderscult.com/php/php-curl/2008/05...

Obeying the POST to modify data

So I've read you should use POST for anything that could modify data. E.g. BAD <a href="edit.php?id=12">Edit</a> GOOD <form action="edit.php" action="post"><input type="hidden" name="id" value="12" /><button type="submit">Edit</button></form> Now obviously the first once is more terse, but it would be considered the wrong way to ...

issue with php sessions

i cant seen to get the php sessions to work, im trying to create a form that saves the data then put its against regular expressions to verify its legit information. at the moment im trying to figure out how to get the sessions to register but i cant figure it out, please help. im new to sessions <?php session_start(); ?> <!DOCTYPE HT...

Random Records Mysql PHP

I've read that it isn't a good idea to run SQL queries with ORDER BY RAND() on large databases. So here's my shot at breaking up the code. The code needs to select 10 random ids from the database, then do a second select to grab the random rows. $sql = "SELECT id FROM table WHERE image != '' ORDER BY id DESC LIMIT 50;"; $result ...

How to get PHP time tomorrow 6pm CST?

I need get a timestamp in PHP for the next day 6pm CST $tomorrow = mktime(18, 0, 0, date("m"), date("d")+1, date("y")); echo "Tomorrow is ".date("Y-m-d H:m:s ", $tomorrow); I was unable to set the minutes part for the above code, it is always returning 11 in the minutes part. Tomorrow is 2009-11-06 18:11:00 ...

Problem with my implementation of the Post/Redirect/Get pattern

I always use the Post/Redirect/Get method on my forms. My forms generally always submit to themselves. However, when I have an error in the form, I don't send any new headers. This is so I can easily do stuff like this <input type="text" name="email" value="<?php echo $this->input->post('email', '') ?>" /> The PHP is just a library fu...

Printer option in php

how to print a document using codeigniter PHP printer option without printer dialog box? ...

PHP array problem

I have an array like this. What i want is to get the value of the index for specific values. ie, i want to know the index of the value "UD" etc. Array ( [0] => LN [1] => TYP [2] => UD [3] => LAG [4] => LO ) how can i do that?? ...

What are differences between error_reporting(E_ALL) and error_reporting(E_ALL & ~E_NOTICE)

I am using PHP. Could anyone explain differences between error_reporting(E_ALL) and error_reporting(E_ALL & ~E_NOTICE)? I noticed that when I change from E_ALL to E_ALL & ~E_NOTICE, an error which I was hacking, disappears. Regards. ...

Fatal error: Class NAME not found in (....PATH) ?

Hi What may be the problem if i get the following error. Fatal error: Class NAME not found in (....PATH) ? I have done most of the possibilities... But i can't resolve the problem. any help will be thankful thanks n advance Fero ...