php

simplexml_load_file and encoding problem

SimpleXML will convert all text into UTF-8, if the source XML declaration has another encoding. So, all the text in the resulting SimpleXMLElement will be in UTF-8 automatically. In my case the source has the following XML decl: <?xml version="1.0" encoding="windows-1251" ?> What should I do so as to get normal output? Because, as yo...

how to update the unchecked checkbox from checked checkbox into mysql using php

how to update the unchecked checkbox from checked checkbox into mysql using php ...

Which php version,ie php 4/5/6/7, should i learn for web development( layout, functionality, and CMS )?

Which version should i learn, php 4, 5,6,7 to create websites with content management? And why. ...

How to get the current time/timezone of the user visiting my website?

I am working on an application which utilizes PHP (Zend Framework) and JavaScript (jQuery). I'm trying to get the current time of the user visiting the site. Is this possible? How can this be done? ...

"Fatal error: Cannot use string offset as an array" when variable is 08 or 09.

I'm writing a script to output Google Analytics API data and insert it into a bar chart using Google Charts API. When I have a string like this in the URL, I get the desired result. gaFeedData.php?y[]=2009&y[]=2010&m[]=1&m[]=2 However, when I have the following string in the URL, I get an error: Fatal error: Cannot use string offset ...

PHP Array trim blank index values

How to trim a PHP array and remove all empty indexes Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => 4 [8] => 6 [9] => ) Output should be like Array ( [0] => 4 [1] => 6 ) ...

Finding the PHP File (at run time) where a Class was Defined

Is there any reflection/introspection/magic in PHP that will let you find the PHP file where a particular class (or function) was defined? In other words, I have the name of a PHP class, or an instantiated object. I want to pass this to something (function, Reflection class, etc.) that would return the file system path where the class ...

JQuery Ajax form submit returns html of the index page

Hey guys I need help. Have an HTML form that I am submitting using JQUERY ajax instead of updating with a server response, it is updating with the index page html. The form <form id="publishimages" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> <input type="submit" name="publishimages" value="Publish Selected" /> </f...

Disable native Soap class in PHP5 and use nuSoap?

I've spent the last week developing code to connect to a Web Service using the nuSoap library. I just deployed the code to production, but immediately started getting error's that I hadn't seen before. I traced the problem back to a line of code that is trying to instantiate a new soapclient object. It turns out that both libraries have ...

Malformed packet error during MySQL LOAD DATA LOCAL INFILE

I am trying to load a file into an MySQL(v5.1.38) innodb table using PHP's mysqli::query and a LOAD DATA LOCAL INFILE query. The query returns a 'Malformed packet' error code 2027. Any ideas what is wrong? Here is the target table: CREATE TABLE `zbroom`.`lee_datareceive` ( `a` varchar(45) NOT NULL, `b` varchar(45) NOT NULL, `c`...

ATOM date format to UNIX in PHP

So this cant be too difficult, I need a feed date/time converted into a unix timestamp in PHP. from "2010-04-13T10:00:00.000-04:00" -> Unix I have been trying all sorts of weird things with date() and strtotime() with no luck. Thank you! ...

When dealing with GD Library unwantedly altering colors

I'm merging multiple small images into a rectangular mosaic.. When dealing with a small number of source images it turns out fine: grab.by/2Y4W (sorry, I'm new and am not allowed to post multiple hyperlinks) But when dealing with a larger number of sources it turns out a sepia like effect: http://grab.by/2Y4P Is there any technique I ...

PHP fgets "noblock"?

I'm trying to build a little command-line IRC client in PHP because I'm getting sick of all those clients having you click through twenty GUI popups/windows to connect to a new server. Everything is working so far, but I'm stuck with the main loop that sends my input commands/messages to the server and receives the new data from it. As...

How to create a SOAP enumeration value in PHP

I'm writing PHP logic that will implement a WebService in SOAP 1.1. The WSDL (which is out of my control) specifies a response type of "enumeration", but PHP doesn't have anything that's formally considered an enumeration. I'm using constant class members instead, which is a common hack for enumeration in PHP. But PHP's SoapServer isn't ...

An array stored in MySQL is not recognized as a value

I am trying to store a json encoded array into a MySQL field. The stored array is in the form: ['value1', 'value2', 'value3'] Then I try and run a query like: SELECT * FROM mytable WHERE arrayfield it returns no results. The arrayfield is either blank or contains an array, so I am trying to get the records that only contain an array ...

What does "pcntl_fork(): Error 12" mean?

I've searched until I was blue in the face and cannot find the answer to this question. Where I can find a table listing the meanings of all the error codes for pcntl_fork()? Or even the C fork() function, for that matter. ...

An rss parser tutorial

Know any updated ones that are good? ...

Replace Second Instance of String

Hey, I just wondering how I could replace the second instance of a string inside a string in php such as follows: a - b - c Where it would add an extra space after the second "-" but only if it finds 2. Thanks ...

Make a php function recursive

I have written a function for a multilevel wordpress menu, but I'd like it to work for any number of levels, at the moment it is written to work for 3 levels. //only gets the top level items $top_level_pages = get_pages('parent=0&sort_column=menu_order&exclude=129,2,13'); foreach($top_level_pages as $page){ //print_r($top_level_pages); ...

Options for PHP CLI on windows

I'm working with the PHP CLI on windows at the moment to write some small desktop command-line apps. I wanted to know if and how it may be possible to: Clear the screen (cls would be the normal command but exec() won't work with it) Change the color, change the color of parts of the output (seen this in programs before) Make the comma...