?

Log in

No account? Create an account
PHP Development's Journal
 
[Most Recent Entries] [Calendar View] [Friends]

Below are the 20 most recent journal entries recorded in PHP Development's LiveJournal:

[ << Previous 20 ]
Thursday, December 2nd, 2010
3:05 am
[cynagen]
phpAPP: Include file to help with shell PHP scripting, command-line switch input parsing.
I've had to re-write this code so many times I finally put it into it's own .inc(lude) file and posted it up online with a demo php application to show off some of the include's abilities so far even in it's limited state. If people could please check it out and give it a try, I'd like to get some feedback on this project as I'd like to make a very robust include file to help myself and others out with shell scripting in PHP.

Yes, I know shell scripting isn't really done in PHP, but it's a very very powerful language, easily capable of being scripted to become a daemon (bot), or some type of service/server, but the one thing lacking and needed for any command line application is switch input. So here I present phpAPP, the shell scripting helper.

# ./phpapp -test[]=var0 -test[]=var1 -test[0]="var2 var2" -test2=29.95 --var_display=test2 --arr_display=test
OUTPUTS:
Display test2: 29.95
Display test: Array
(
    [0] => var2 var2
    [1] => var1
)

This is just an example of some of the basic stuff you can accomplish with this.
http://www.cynagen.com/home.php?page=phpapp -- Latest version will always be available here. Again, please comment.

Current Mood: anxious
Wednesday, June 30th, 2010
12:22 am
[lostaddiction]
XML->PHP resources
So this one will probably make all the XML experts squirm and itch inside, but i need to ask so my apologies upfront.

I was wondering if anyone could point me to some online resources where I can learn to manipulate xml data.

I currently have a .xml document with all the data in that i need, and want to construct php classes and functions to break down the data into relevant variables that i can then display in a php file.

I can already tell you will all be screaaming "learnit from the start!!!", but I need somewhere that will help me focus on identifying the data needed, accessing the right categiory or sub category for the data, and pulling it out into a variable. Whenever I look at xml stuff, i get frustrated coz it feels liek a familiar code but i'm missing bits of knowledge that stop me from really getting to grips with it :(

let the flaming begin, lol.
Wednesday, April 14th, 2010
3:42 pm
[socialfootball]
Startup is looking for developers (Moscow, Russia)
Hi there!
Hope developers from Russia are reading this community, cause we're looking for great professionals in Moscow. Even got special prizes for them. We're the team of Russian startup tournament called Harvest@GreenfieldProject. It'll be held on 17th-18th of April in Moscow. So if you're from Russia, pls read the text below and join our event!

Разработчики – самые дефицитные специалисты в стартапах. Поэтому на новом Harvest (РИФ+КИБ edition) мы создали вам особые условия.

Harvest (РИФ+КИБ edition) – стартап-турнир, на котором за 2 дня можно успеть то, что не получалось доделать месяцами. Победившая команда получит полностью оплаченную поездку на учёбу в летней бизнес-школе Ignite в Кембридже (Англия).

17-18 апреля пройдёт отборочный турнир для стартапов любой степени готовности: от задумки, презентуемой впервые, до развитого проекта, которому не хватает рук. Как советует Ричард Брэнсон «К черту все! Берись и делай!»
Read more...Collapse )
Подробная информация и регистрация участников на сайте стартап-турнира: http://harvest.greenfield-project.ru/
Цена участия для разработчика составит всего 600 р. Снизить её еще на 20% можно, оплатив через интернет.

Тем, кто зарегистрировался, достаточно приехать 17 апреля с ноутбуком, знаниями и опытом в МФПА на “Семёновской” (100 м. от метро). Остальное – интернет, питание, аудитории и интересных экспертов – обеспечит команда организаторов.
Friday, March 26th, 2010
10:48 am
[mmmissymunchkin]
simple PHP code for retrieving text from another .php file
Hi I need a little help with this. I'm looking for a simple PHP script that i used to have and now im having difficulty finding it. All the script does it retrieve the data from another webpage created on your server, so when you click the link (/index.php?page=contact) and the page reloads, the page will have that data in the content area of your index template.

I don't remember this code ever needed a database.
Can anyone help?

Current Mood: aggravated
Friday, February 12th, 2010
8:16 am
[util]
getting reference to array value changes structure of array?
I'm surprised to see the var_dumps aren't identical. Is there any reason in practice to worry about the difference between them? Also, in general, is code like following frowned upon? I'm building up a data structure through reading rows from a database -- an array of arrays.
<?php

function &EmptyIfMissing(&$anArray, $key) {
  if (!array_key_exists($key, $anArray)) {
    $anArray[$key] = array();
  }
  return $anArray[$key];
}

$a = array();
$b = &EmptyIfMissing($a, 'B');
$b['C'] = 'C';
var_dump($a);
var_dump(array('B'=>array('C'=>'C')));
has output
array(1) {
  ["B"]=>
  &array(1) {
    ["C"]=>
    string(1) "C"
  }
}
array(1) {
  ["B"]=>
  array(1) {
    ["C"]=>
    string(1) "C"
  }
}
Sunday, August 16th, 2009
9:56 pm
[lostaddiction]
paypal express checkout
Does anyone have any experience of installing paypal express on a custom built shopping cart? i'm getting absolutely nowhere and and starting to lose the will to live :( Is there any kind sole willing to have a look at the code for me? maybe even correct it, test it, make it work? for a little bit of cash? None of the online tutorials i've found make any sense :/

I've got a business account set up and have the API details, and i have a sandbox account with API details. The express button is on the checkout page and takes me to paypal sandbox. but it doesn't seem to be taking the order details through with it. I also need the site to update the database to say payment has been received and the order should be shipped to the paypal address.

Anyone feeling helpful and kind? :) pretty please? I need this doing as sooon as possible.

[x-posted a little]
Tuesday, April 21st, 2009
7:20 pm
[lostaddiction]
explode help needed
[solved, thanks to darac]

Me again! And i may be back for more help later too! hehe

Anyways, i need some help with the explode function in php.

If i have an Array of words, how do i display that array and have commas inbetween each word?

From:
Array (
     [0] => one     
     [1] => two     
     [2] => three
     [3] => four five six
 ) 


How do i get it to display onscreen as:
one, two, three, four five six

The important thing is to *not* have a comma at the very end.

thanks in advance! :)

Paul
Sunday, April 19th, 2009
11:38 pm
[lostaddiction]
Prev/Next item with MySQL
[solved, thanks to synergetic]

HiGuys,

Needing a bit of help with MySQL queries. Hopefully someone has the answer, or a pointer at least :)

Say I have a page displaying an item, www.domain.com/item.php?id=12 and at the bottom of that page i want to have a Previous link and a Next link which will link to the previous and next item in the database, how do i call the item numbers? I don't want to just do $id - 1 or +1 becausethe next item might be number 14 for example, not 13.

So before the links are displayed, i need some way of saying the id is 12, look at what the next number is in the id column and select that one. So it's not just a prev/next page link, but prev/next item in the DB link.

Hopefully my laymans terms aren't too confusing!

Any ideas? :)

many thanks,

Paul
Tuesday, March 10th, 2009
12:35 pm
[lostaddiction]
php driven image gallery - help needed
[solved, thanks to thenetimp]

(x-posted to php)

Hey guys,

I'm coding an image gallery to use on my PHP site and need a bit of help with a couple of features I want to code into it. I was hoping someone here could either give me some pointers or send me to a website that will help with either explainations or code snippets :)

1. Firstly, thumbnails. I have created an admin panel where I upload the images and can set various things like the category, title etc, and all that is stored in a MySql database, and the file uploaded to a general directory. But i'd also like to create a thumbnail of the image as it uploads. I've found several scripts that make thumbnails from images already in a directory, but i'd like it to happen as I upload the image. Is that possible? Without having to use some all-in-one image gallery script heh. I'd also need it to resize the image proportionally so that images aren't just squashed into a 100x100 square shape.

2. Secondly, I'd like to "tag" images like with LJ entries, so that on the front end when a picture is being viewed, the list of tags is shown and can be clicked on to show other image thumbnails with the same tag. But i'm not really sure how to go about this... I was just going to have a table field called img_tags and store them all in that per image, but then is that efficient? searching for matches within a db field? any tips or suggestions?

3. oh and as an extra thought, how can i then take those tags and make a tag cloud maybe?

All and any help would be most appreciated! :)

paul
x

Current Mood: puzzled
Thursday, February 19th, 2009
7:11 pm
[thenetimp]
accessing an object like an array
I am hoping someone can point me in the right direction.

I have an object that at some point sets one of it's variables as an array.


class myClass
{
  private $data = array()

  public function __construct($newData=array())
  {
    $this->setData($newData);
  }

  public function getData()
  {
    return $this->data;
  }

  public function setData($newData=array())
  {
    $this->data = $newData;
  }
}

$dataObj = new myClass($someDataArray);

// I want to be able to do.

print $dataObh['myArrayKey']

// and get back the data that that key holds in the object $data variable




I know it can be done, I just don't know the specifics, and I think it has something to do with Obect Iteration, but the docs are confusing me. Thanks.
Thursday, December 25th, 2008
4:04 pm
[thenetimp]
Event Calendar.
I am trying to write an event calendar application. For no other reason than the learning experience, so please don't answer by "go use google calendars". You don't learn anything that way.

I have written the part that builds the display of the calendar. I found a class that built a display, but it had all the HTML in the class so I rewrote it to be more of what I wanted.

Now I want to create the database to store the events. I want to enter an event by date. I want to be able to add an event every 2 weeks on thursday, every 3 months on wednesday, but I am not sure how to approach putting that in the database. Looking for some database structure suggestions.
Thursday, May 29th, 2008
10:28 am
[varenich]
Guide to PHP script protection
Hi,

Are you interesting in information that will guarantee you the full protection of your sites made with PHP scripts?

Is this book useful for you?

If yes, please advice me the information you'd like to see in the book:

- What was the point caused you to start digging PHP script protection?
- Why do you need the information on PHP script protection? What do you want to do next after you get one?
- What subjects you really need to know about PHP script protection?
- What are your doubts and questions on PHP script protection?
- What facts you'd like to learn?


Thank you for your cooperation,
Eugene
Sunday, March 30th, 2008
3:08 pm
[thenetimp]
OK so I am trying to figure out if this is possible in php, I haven't had to do it before, and I haven't been able to find anything in the docs, or by googleing (maybe just not searching for it properly).

Let's say I have this bit of code. Pretty simple so far. One class that has a function that creates an instance of the 2nd class.

<?php


$myClass = new FirstClass();
$myClass->doSomething();

class FirstClass
{

    protected $myValue = null;

    public function printMyValue()
    {
        print $this->myValue;
    }

    public function doSomething()
    {
        $this->myValue="testing";
        $secondClass = new SecondClass()
        $secondClass->doSomething();
    }

}

class SecondClass
{
    public function doSomething()
    {
        // call FirstClass::printMyValue() here somehow....

    }
}

?>


What I am trying to figure out if I can do is from the function test2 in SecondClass can I call the printMyValue function in the Instance of Firstclass that instanciated the SecondClass object. I would like to do it without passing the FirstClass directly with $this. And I don't want to use FirstClass::printMyValye() as I lose the value passed in from FirstClass::doSomething()

Thanks,
Wednesday, January 9th, 2008
9:42 am
[thelovebug]
400 Bad Request
This may not be a PHP issue, but I'm trying to cover all my options here.

I have written a photoblog site at http://eye.thelovebug.org/

As you can see, it works a treat through a browser, and also by using wget. However, if I try and validate the site, I get a 400 Bad Request error.

link to W3C validation of eye.thelovebug.org

The same problem occurs with my homemade RSS feed at http://eye.thelovebug.org/rss.php

Again, works great with a browser and wget, but doesn't validate or load in Google Reader (or other RSS aggregator), or LiveJournal. Same 400 error.

link to LiveJournal syndicated account profile
link to feedvalidator.org validation of eye.thelovebug.org/rss.php

Any ideas or suggestions?

Cheers,
Dave
Wednesday, November 14th, 2007
2:54 pm
[josienutter]
+/-
This may be a dumb question, but does something like this exist in PHP?

$int1 = int2 +/- int3;

(?)

I can't find anything on php.net, so I'm guessing no.  But it never hurts to ask, right?

Current Mood: curious
Wednesday, October 17th, 2007
2:21 pm
[satim]
Hi guys. I need help in PHP spam protection (captcha)
I don't know PHP absolutely. I have a PHP e-mail form on my website (http://www.toondra.ru/en/contact.htm) and I have problems with spam. Can you help me and add Captcha code to HTML code of that page? I found that (http://captchator.com/test.php.txt) but it's hard for my understanding :)

If you can help me please send me fixed PHP page (http://www.toondra.ru/en/contact.htm)

Thank you!
Friday, October 12th, 2007
3:29 am
[lrdjester]
xhtml (php) to doc (rtf) or pdf
Is there a way to convert xhtml formatted documents as a document/rich text file or a pdf on the fly?

I have looked at htmldoc, but it does not support css in the current release and even in the upcoming 1.9 release, only CSS1 tags are supported and not the positioning tags.

What I am looking to do is create my resumé in an xhtml 1.0 or 1.1 document and be able to have it convert to word or even pdf. All the agencies that have been contacting me have requested a doc format of my resumé. I have a doc (and pdf) version, but I hate having to do double entry and then save to pdf. I could save as html in OO.org, but I hate doing that. I like the clean xhtml resum&eacue;.

My resumé can be found here. Already, there is a revision difference on the technical resumé. Also, the non-technical version is not offered up in doc and pdf.

I have searched quite a bit and fond services, but they are using the aforementioned htmldoc toolkit. There is a lot of hits on rtf to xhtml, but not vice versa.

Thanks for any help you can give.

Jeff

Current Mood: frustrated
Saturday, June 9th, 2007
12:57 am
[hisrealm]
This one ERROR is driving me nuts
I am not sure how to fix this error in my xhtml 1.0 transitional validation.

w3c validation of the page

I don't ever remember this error being there.

Suggestions?

Current Mood: annoyed
Thursday, May 24th, 2007
11:24 pm
[thenetimp]
Creating a "nonce"
I am working on a class for a web services API. I have decided to go with WSSE based on this article.

http://www.xml.com/pub/a/2003/12/17/dive.html

In the article it mentions the need to create a nonce. I am trying to figure out the best way about going about this. Anyone have any ideas or articles I can read? I haven't found anything good via google.
Saturday, April 28th, 2007
10:50 pm
[thenetimp]
SimpleXMLElement Question.
I am connecting to Amazon's S3 web service. I've created 2 buckets, and am now writing a function to get back the list of buckets from S3, and am having problems parsing the XML with simple XML.

I've got down to the bucket Node in a foreach loop as $bucketObj in the XML this Node had "Name" and "CreationDate" as XML nodes.

$bucketObj->Name;
$bucketObj->CreationDate;

The problem is when I call them instead of getting a "string" variable, I have a "SimpleXMLElement" If I var dump Name it looks like

    object(SimpleXMLElement)#17 (1) {
      [0]=>
      string(13) "JamesTest1234"
    }


How do I get access to [0] I've tried all kinds of things. If it was ['0'] I'd know how to get it, but in this case when I try $bucketObj->Name->0 it fails I've also tried $bucketObj->Name[0].

I'm really confused. I've used SimpleXML before and hadn't had any kinds of issues like this, so any suggestions would be greatly appreaciated.

This is the XML I receive with a little modified info:
<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>amazon key data</ID>
        <DisplayName>amazon</DisplayName>
    </Owner>
    <Buckets>
        <Bucket>
            <Name>JamesTest1234</Name>
            <CreationDate>2007-04-29T01:08:47.000Z</CreationDate>
        </Bucket>
        <Bucket>
            <Name>JamesTest12345</Name>
            <CreationDate>2007-04-29T01:10:47.000Z</CreationDate>
        </Bucket>
    </Buckets>
</ListAllMyBucketsResult>
[ << Previous 20 ]
About LiveJournal.com