php

PHP Parse Error

I am trying to add an echo statement after the line: echo '<td class="today" valign="top"><a class="monthnav" href="dayPlanner.php?d='.$day.'">'.$day.'</a></td>'; It is just a simple echo ''; (Really I am trying to break the line up to not include the in the same echo statement, so I can insert some more code later. I however am ge...

PHP: socket listen problem

Here is my code: <?php $host = "127.0.0.1"; $portListen = 1234; $portSend = 1240; // create socket $sSender = socket_create(AF_INET, SOCK_STREAM, 0); socket_connect($sSender, $host, $portListen); socket_write($sSender, "test", strlen ("test")); $sListen = socket_create(AF_INET, SOCK_STREAM, 0); socket_set_option($sListen, SOL_SOC...

Problems with imagesetpixel and displaying the image with php5 and gd 2.0 (or higher, apparently)

I'm trying, for reasons best known to my unconscious mind, to generate a snow-crash-like picture. Using PHP5 and GD v2.0 (or higher), I'm using the following php/html: <?php $x = $y = 100; $gd = imagecreatetruecolor($x,$y); $w = imagecolorallocate($gd, 255, 255, 255); $b = imagecolorallocate($gd, 0, 0, 0); ...

Codeigniter: MySQL where clause, and quotes

Here's my query in Codeigniter: $this->db->select('comments.created_at, comments.section_id, comments.submittedby_id, users.username, comments.text, sections.name'); $this->db->order_by('comments.created_at', 'desc'); $this->db->where('comments.submittedby_id', 'users.user_id'); $this->db->where('comments.section_id', 'sections.id'); ...

How do I add new elements to XML using PHP DOM deeper than the root?

All of the examples I can find online about this involve simply adding content to an XML file at the document root, but I really need to do it deeper than that. My XML file is simple, I have: <?xml v1 etc> <channel> <screenshots> <item> <title>Image Title</title> <link>www.link.com/image.jpg</link> </item> </screenshots> </channel>...

Initiate a class by calling a function that returns an instance of that class - PHP?

class foo(){ function bar() { $classInstance = $this->createClassInstance($params); $result = $classInstance->getSomething(); } function createClassInstance($params) { require 'path/to/class.php'; $myClass = new Class; $myClass->acceptParams($params['1']); $myClass->acceptMoreParams($params[...

How do I get the first day of the week for the current locale? (PHP / L8N)

In most locale, the first day of the week is Monday. In the US (and presumably elsewhere), the week starts on Sunday. How can find out in PHP, for an arbitrary locale, the current setting for the first day of the week (Sunday or Monday)? Thank you. ...

Egg-chicken problem in OOP way

Hi Guys, I have a chicken-egg problem. I would like too implement a system in PHP in a OOP way, in which two classes would play important roles: Database and Log. My idea was to build up the connection by the Database class, which would have public methods eg. runQuery(sUpdateQuery), doInsert(sInsert), etc. The Log class would writing l...

PHP - Maximum Total Upload Size?

I have a php web page with 15 fields. The user will use it to upload images. I tested this by uploading 15 jpg images, each about 2 M, without any problems. On the day I launch, I will be moving this web page to another Linux shared hosting environment (still not sure which). Are there some web hosting environments that limit the si...

How can I generate a v2 signature for Amazon EC2 using PHP?

I am wondering if anyone has successfully generated an EC2 v2 signature for there API using php. All examples/libraries I can find online are for v1 of the signature and that has been deprecated due to insecurities. An existing library that implements the signature generation would be appreciated too. ...

Set attributes for parameters in SOAP request PHP

hey there I'm trying to use a webservice which only allows SOAP request as far as I know I must create a request that looks like this <?xml version="1.0" encoding="utf-8"?> <SessionCreateRQ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <POS> <Source PseudoCityCode="SECRET_...

parameters in MySQLi

Hi - I'm using PHP with MySQLi, and I'm in a situation where I have queries like SELECT $fields FROM $table WHERE $this=$that AND $this2=$that2 So far I've written some code that splices up an array that I give it, for example: $search = array(name=michael, age=20) //turns into SELECT $fields FROM $table WHERE name=michael AND age=2...

Refactoring a method having dependencies within the same object into something more testable (PHP)

I currently have a method within my class that has to call other methods, some in the same object and others from other objects. class MyClass { public function myMethod() { $var1 = $this->otherMethod1(); $var2 = $this->otherMethod2(); $var3 = $this->otherMethod3(); $otherObject = new OtherClas...

Is it possible to preload page contents with ajax/jquery technique?

Is it possible to preload all page contents (like showing a loading bar / animated gif.. or loading text.. ) until the contents are fully loaded and then displayed to the user/visitor ? If this is possible, can you give me just directions or resources to follow to achieve this. Because I was able to find image preloaders easily, but I am...

PHP curl post to login to Wordpress

i am working on a project for a client which needs an automatic login from a link click. I'm using a handshake page to do this with the following code: $username="admin"; $password="blog"; $url="http://wordpressblogURL/"; $cookie="cookie.txt"; $postdata = "log=". $username ."&pwd=". $password ."&wp-submit=Log%20In&redirect_to=". $url ...

problems sending email to SMTP with PHPMailer

I get the following error log when trying to send a message through an Exchange server: SMTP -> get_lines(): $data was "" SMTP -> get_lines(): $str is "220 mail.borschow.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Tue, 7 Apr 2009 21:56:53 -0400 " SMTP -> get_lines(): $data is "220 mail.borschow.com Microsoft ESMT...

Efficiently searching a 3-level hierarchy

Lets say I have a FirstName > MiddleName > LastName hierarchy (~10k rows, for sake of the question). This means you could have "John > Mary-Anne > Eddy" or "Eddy > John > Jacob" row. The point being that the hierarchy makes little sense and is very foreign to the user (unlike, say, a Country > State > City structure). Because its so u...

Best way to download a file in PHP

Which would be the best way to download a file from another domain in PHP? i.e. A zip file. ...

How can I add missing index in an array in php??

Example: I have and array like this: Array( [0] => Apple [2] => Orange [5] => Pear [8] => Pear ) there are a function to complete the missing indexes: 1,3,4,6,7???? ...

Remove excessive line returns

I am looking for something like trim() but for within the bounds of a string. Users sometimes put 2, 3, 4, or more line returns after they type, I need to sanitize this input. Sample input i like cats my cat is happy i love my cat hope you have a nice day Desired output i like cats my cat is happy i love my cat hope you have...