php

How to get only required xpath elements?

Hi Guys, I have an xml file that I want to store a node's rank attribute in a variable. I tried: echo $var = $xmlobj->xpath("//Listing[@rank]"); to no avail, it just prints ArrayArray. How can this be done? if($xmlobj = simplexml_load_string(file_get_contents($xml_feed))) { foreach($xmlobj as $listing) { ...

What is the current way in which I can add an object to the database using Zend Framework?

I want to save an object or form to the database. Only I can't find the easiest (or normal) way for how to do this. I found a lot of tutorials, but none seem to be easy or current. Can someone please help me with this? I use version 1.9.3 of the Zend Framework. ...

MySQL: How to store/retrieve artist information?

It's very confusing; it seems like I'll need to have at least one many-to-many relationship. A track might be sung by 2+ artist - how can I store that in the database? While showing that track, I want link to each artist so that when users click the track it opens that artist's profile page. Can anyone provide me with some assistanc...

How to manipulate first 3 entries in array

Hi I am currently working on a project where i am pulling out data using while($r = mysql_fetch_array($the_data)) i want to make the first, say 3-4 results a different background color and then leave the rest as already styled, i am sure there is some simple option here but i just don't know where to look really... Hope you can help, ...

php : echo"", print(), printf()

Is there a better way to output data to html page with PHP ? if i like to make a div with some var in php i will write something like that print ('<div>'.$var.'</div>); or echo "'<div>'.$var.'</div>'"; what is the PROPER way to do that ? or a better way, fill a $tempvar and print it once? like that: $tempvar = '<div>'.$var.'</di...

Overcome Wordpress Memory Exceeded Limit, WITHOUT changing server's limit.

My server's limit is set to 8MB. I want wordpress to work, however it must be incredibly bloated if it needs to use over 8MB just to get to the admin page. I have no plugins, it's a fresh install. Is there anyway i can strip it down so that it no longer causes this error? I will not change the memory limit to larger than 8mb ...

PHP: SPLFileObject next() behavior

Hi there, In PHP SPLFileObject allows treating files as iterators. Yet there is a behavior that I don't understand. When you call next() on the object it increments the value of key() but does not advance the line in the file unless you call current() with each iteration. The SPL docs state that key() returns current line number. Code...

How to remove new line characters from data rows in mysql?

I can loop through all of the rows in a php script and do UPDATE mytable SET title = "'.trim($row['title']).'" where id = "'.$row['id'].'"; and trim can remove \n But I was just wondering if something same could be done in one query? update mytable SET title = TRIM(title, '\n') where 1=1 will it work? I can then just execute this...

wordpress multiple loops problem

i am trying to build up a single.php page. this page is used to show a full single post. i have 3 loops on it. first two are used (each) for geting a random post from a specific category. 1 <?php query_posts(array('orderby' => 'rand', 'category_name' => announcement, 'showposts' => 1)); if (have_posts()) : while (have_posts()) : the_p...

PHP, json_encode, json_decode of SimpleXML Object

A function in my application does the following: Capture Web Page using Snoopy Load result into DOMDocument Load DOMDocument into Simple XML Object Run XPath to isolate section of document required json_encode the result and save to database for later use. My problem arises when recovering this block from the database, and decoding i...

Java or Python for an intermediate PHP guy. Career advice.

I'm an intermediate PHP developer looking to take up a new language. I'm completely torn as to where to go at this point. There's so many languages related to web development and programming in general. I had might as well add Ruby to the question. Java, Python, or stick with PHP and try to really master it? For those of you program...

Rebooted and php mail script is failing again on OSX

I was having trouble getting my mail php mail script to work yesterday but I finally got it going. Now I just turned my computer back on after a shutdown and its not working again. I am getting this message in my mail.log: Oct 1 11:22:26 alexander-repennings-imac postfix/sendmail[352]: fatal: Recipient addresses must be specifie\ d o...

How can I retrieve the contents of a HTML text box from PHP in response to a button click?

What is the best way to put a text box on the following HTML page and then, without reloading the page, get its content in PHP when the user clicks the button? <?php require_once "phpuploader/include_phpuploader.php" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <h...

How to encrypt/decrypt text from file with php?

How to encrypt/decrypt text from file with php? ...

PHP Import Foreign Class' Method into MyClass

Wondering if this is possible in PHP Land: Let's say I have a class as follows: class myClass{ var $myVar; ... myMethod(){ $this->myVar = 10; } } and another class: class anotherClass { ... addFive(){ $this->myVar += 5; } } The 'anotherClass' is 3500 lines long and I just want the single 'addFive' m...

PHP __call vs method_exists

The Project I'm working on contains something like a wrapper for call_user_func(_array) which does some checks before execution. One of those checks is method_exists (In Case the supplied first argument is an instance of a class and the second is a method name) The other is_callable. The function will throw an exception if one of those c...

Trimming A Vertical Bar

Hi guys, In PHP the trim function has a parameter for trimming specific characters (handy for leading zeros and the like). I can't seem to get it to accept a vertical bar (|) character. Anyone know how to get this working? I tried the hex value but had no luck. I'm sure it's something simple. Cheers ...

Session 'disappearing' on some machines

I'm not exactly sure the question I should be asking. Sorry! I'm working on re-doing my web site so as to be using PHP5. The server lives in a buddy's basement and I just ssh in to do my coding and view the pages just like any other page out there. I keep track of login details in $_SESSION. When I'm sitting at my home machine I c...

Jquery delay link redirection for ajax

When a link is clicked, I want to clear the php session before redirecting to the destination page. The way I thought of doing it is by loading a php script that clears the session with ajax in the origin page and once that script has loaded, to redirect to the destination page. Here is the code I have: $(document).ready(function() { ...

What does it take to utilize SSL?

I just purchased an SSL certificate from my hosting provider, at the request of a bank I'll be doing Credit Card transactions with. As of yet, I'm not sure if I'll be sending my users to their site to do the transactions or if I'll just be sending CC information to their site to do the transactions. My confusion is in regards to coding a...