php

How to extract a value of an HTML input tag using PHP

I know regex isn't popular here, what is the best way to extract a value of an input tag within an HTML form using a php script? for example: some divs/tables etc.. <form action="blabla.php" method=post> <input type="text" name="campaign"> <input type="text" name="id" value="this-is-what-i-am-trying-to-extract"> </form> some d...

PHP - ob_start("ob_gzhandler") why the function not use directly in zend framework project?

Hi, I beginer in zend framework. ob_start("ob_gzhandler") - why the function not use directly in zend framework project? (does ob_start("ob_gzhandler") used auto in zend framework? ) Thanks ...

Store path of a photo in codeigniter

Hello, I followed this tutorial on how to upload a photo in a codeigniter folder: http://codeigniter.com/user_guide/libraries/file_uploading.html Can anybody tell me how can I store the path of the photo I just uploaded in my db? Let's say have table called photo_paths thanks in advance ...

hyperlink starting slash?

In my php script I created a constant variable that defines the base url to be put in my hyperlinks, but do I really need this? Here is an example of what I mean. I have this: // base url is only defined once and reused throughout define("__BASE_URL","http://localhost/test1/"); print '<a href="'.__BASE_URL.'index.php?var1=open/>Ope...

Trouble with 2 session_id()'s on my site - PHP/Jquery.

I'm trying to build a site that runs without refreshes, using Jquery and PHP to populate divs that slide in/out. basics work OK, but I am having trouble passing session values around. I have a login panel first that captures "$user" in PHP and then stores is as a session variable $_SESSION['user']. I can then use it on the first page...

How should i implement this in OOP?

How would you handle grouping different objects? For example, lets say you have a book of sport cards and you want to organize and spit out data about that book of sport cards. Obviously each sport card should have its own class and be its own object, but how would you group different sets of sprots cards? What if you wanted to see how...

How to run a background process in PHP and read/write its stdout/stdin?

As an extension to question "php execute a background process": Suppose I wanted to keep a process running during a PHP session, like an interactive bash shell. How can I establish redirection of stdout/stdin such that PHP can read/write to the process? UPDATE: The key is to be able to kick off the process and keep it running in the b...

ORM in Django vs. PHP Doctrine

I am a PHP guy. In PHP I mainly use Doctrine ORM to deal with database issues. I am considering move to Python + Django recently. I know Python but don't have experience with Django. Can anyone who has good knowledge of both Doctrine and ORM in Django give me a comparison of features of these two ORM implementations? ...

Why does Jquery ajax add slashes to String?

Possible Duplicate: jQuery: How to stop AJAX function escaping JSON string used to POST data I make a jQUERY ajax call to send and save to data.When I send Google's Dog string, I receive Google\'s Dog . What is the reason of this . And what is the best way yo avoid this. I do not want to use stripslashes function because this ...

php session variable not updating a 2 dimensional array after initializing...

I'm almost embarrassed to ask because it seems so simple, but I can't get it to update. When the user logs in I set the session vars like array('users'=>array('timezone'=>'America/los Angeles')); I can then retrieve the data as follows: $_SESSION['users']['timezone'] and it works fine. However in the user profile page the user can ch...

PHP Retry Script until Success or Error

I'm trying to create a php script which retries another php script up to 3 times until an error is displayed. I'm thinking perhaps this could be done using a php loop? If the code works successfully the first time, then there is no need for it to retry 3 times, however, if it doesn't work the first time, then it should retry the php scri...

Doctrine - getChildren() with conditions?

Hi, I'm trying to write a basic plugin for the Symfony based CMS Diem. I'm trying to list of the child pages for the current page, which I have managed to do: $page = $this->getPage(); $this->subpages = $page->getNode()->getChildren(); However, I'm unsure of the syntax to use in order to filter the child records with conditions. I ...

How can I cache or evalute a modified version of PHP?

I have a modified version of PHP which is compiled to PHP, in PHP. I'm not interested in a discussion about why I shouldn't be doing this; best practice, standards, etc; so please don't. It's not modified in the core, but crudely uses a PHP script to modify each PHP file before being evaluated. Because of the performance hit of modfiyin...

PHP - returning different types of values from same method

Hi, would it be considered bad practice to return different types from the same method in php. Maybe there is a best pattern for this but essentially i want my method to do something and if it fails return a string error message but if it works then return true. This doesnt seem quite right to me but the only other way i can see to make...

PHPUnit, mocked interfaces, and instanceof

Sometimes in my code, I'll check to see if a particular object implements an interface: if ($instance instanceof Interface) {}; However, creating mocks of said interface in PHPUnit, I can't seem to pass that test. // class name is Mock_Interface_431469d7, does not pass above check $instance = $this->getMock('Interface'); I under...

PHP Fatal Error. Does empty() try to alter the results passed into it?

Ran into a strange problem in PHP today and I'm wondering if someone can explain it. While comparing two arrays I initially tried something like this: echo empty(array_diff( array('foo','bar') , array('bar','foo') )) This results in the following error: Fatal Error: Can't use function return value in write context Rewriting thi...

2 sql in one php while loop.

I'm a bit of a novice to PHP and MySQL. I'm creating my own little news blog for the heck of it. I got to display the information I wanted, but what I want to do is count the number of comments. I made 2 tables, the first table is the article and the other is the comments. I not to sure of how to figure this out. Can anyone help? $...

PHP array to JS array with jQuery and json_encode

I just want to get my PHP array to a JS array, what am I doing wrong here? PHP: // get all the usernames $login_arr = array(); $sql = "SELECT agent_login FROM agents"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { array_push($login_arr, $row["agent_login"]); } $js_login_arr = json_encode($log...

tempnam falling back to /tmp

The PHP function tempnam is failing to create a temporary file in the directory i'm passing to the function and falling back to /tmp/ I have error reporting turned on but no errors are actually being thrown, what should i check? Thanks. ...

extract value from session value - using php unserialize, preg_split or other tool

I have a session variable that contains the following string. a:2:{s:7:"LoginId";s:32:"361aaeebef992bd8b57cb3e8d";s:8:"Username";s:6:"aaaaaa";} echo $_SESSION["SecurityAccess_CustomerAccess"]; I am trying to extract the username "aaaaaa". What combination of unserialize, preg_split or other will get me there fastest? attempts so far...