php

Empty PHP SSH2 stream contents, even with stream_set_blocking?

I am working on a tool that reads an iptables configuration from a remote host over SSH2 using the PECL SSH2 extension. I am able to successfully make the connection to the host, authenticate, and execute commands. The trouble I am having is sometimes the stream doesn't contain any data. /** * Load the current firewall configuration ...

AJAX - PHP Communication patterns

I'm building a webapp in MySQL/PHP/Javascript. In PHP, I've got all the classes from the domain od the problem which persist in the database. In Javascript, there is a cache with objects from the last queries. When an object in Javascript is updated by the user, it has to update itself in server-side. Which would be the best way to do ...

Store data in mysql (data-migration)

Hi, guys! I'm trying to make an online dictionary for my own purposes (I know there are some other dictionaries, but they don't have what I need) and I have a file with words in the following format: 戚谊 戚誼 [m1][b]qīyì[/b][/m] [m2]some translation[/m] 三州府 [m1][b]sānzhōufǔ[/b][/m] [m2]translation #2[/m] First two lines ...

Just a question about str_replace

Hello, I have a question about str_replace in PHP. When I do: $latdir = $latrichting.$Lat; If (preg_match("/N /", $latdir)) { $Latcoorl = str_replace(" N ", "+",$latdir); } else { $Latcoorl = str_replace ("S ", "-",$latdir); } print_r($latdir); print_r($Latcoorl); print_r($latdir); gives :N52.2702777778 but print_r ($Latco...

How to make set up condition specific password in php?

I am learning php on my own. I am creating a new user register page using php/mysql. I want to make sure that the password entered by user in condition specific, that is, must contain one upper case letter, one number and one special character. Any suggestions? ...

Watchpoints w/xDebug in Eclipse PDT?

Has anyone gotten watchpoints to work when debugging PHP with xDebug and Eclipse? The way I understand it, I'm supposed to be able to select a watched variable in the expressions view or select a variable in the Variables view during debugging, and then select Run->Toggle Watchpoint. But Toggle Watchpoint is constantly greyed out. All my...

How can I match the domain part of a URL in PHP?

I'm so bad at regexp, but I'm trying to get some/path/image.jpg out of http://somepage.com/some/...etc and trying this method: function removeDomain($string) { return preg_replace("/http:\/\/.*\//", "", $string); } It isn't working -- so far as I can tell it's just returning a blank string. How do I write this regexp? ...

PHP forum software that integrates easily with existing website?

I have an existing php website with a user system already set up (registration, authentication, lost password, etc.). I've decided that I want to add a message board and integrate it with the existing website: registration on one should register on the other, and similarly with logging in and changing user information. Is there a good f...

Do I have to use .ini configuration with Zend Framework?

Hi, I am learning Zend Framework recently. I followed zend framework quickstart and...it was great. One thing I did not like was using .ini file to set bootstrap path, class, and other things. Is it possible to set configurations using code only? I googled it, but no luck. ...

Simple formatting of multidimensional array from mysql in php

Hello. I have an array of results from mysql relational tables. It looks similar to this: array(10) { [0]=> object(stdClass)#14 (35) { ["eventID"]=> string(1) "1" ["eventTitle"]=> string(7) "EVENT 1" ["artistID"]=> string(1) "1" ["artistName"]=> string(8) "ARTIST 1" ["artistDescription"]=> s...

Offloading script function to post-response: methods and best-practices?

First, the set up: I have a script that executes several tasks after a user hits the "upload" button that sends the script the data it need. Now, this part is currently mandatory, we don't have the option at this point to cut out the upload and draw from a live source. This section intentionally long-winded to make a point. Skip ahea...

Categorizing non-ID categories PHP loop

On my project there're various search results of different content-types. For unimportant reasons, not all content-types carry a unique ID. However, I tried to write this loop that will detect IDless content-types, and will give them a unique ID. Basically, the results look like this: Category ID 3 Category ID 3 Category ID 4 NON-ID C...

zend_config_ini broke after upgrade to zf 1.9

Hello. I recently upgraded my zend framework install from 1.7 -> 1.9. Everything was working prior to the upgrade. I've managed to correct all issues except this particular one. My problem is this. When calling values form a zend_config _ini object the standard 'Setting=Value' scheme works, as long as the setting is not an integer. I...

how to limit my mysql select characters

I am grabbing info from three rows in my table, and echoing one of them in a anchor tag. How can I limit the amount of characters on the $title variable that are shown in the anchor tag. Code: $results = mysql_query("SELECT * FROM news "); while($row = mysql_fetch_array($results)) { $id = $row['id']; $title = $row['title'];...

Why can't my browser see my hosted php files?

I'm sure I'm doing something dumb, but I can't tell what it is. On my remote host, I have a subdir with a bunch of files. When I request this directory, I can see a listing of the files within this dir. However, if request any file suffixed .php, my browser says that the resource is not available. Firefox tells me that it can't find th...

Disable wordpress auto search for related posts

I am working on making urls like example.com/profile/username to work where example.com runs Wordpress(latest release). The install is on root. I wrote a plugin hook to catch template_redirect and I examine the URL to see if it is a profile request and then I show the profile. But, when a URL that does not exist is typed, Wordpress does...

SIMPLE PHP MVC Framework!

I need a simple and basic MVC example to get me started. I dont want to use any of the available packaged frameworks. I am in need of a simple example of a simple PHP MVC framework that would allow, at most, the basic creation of a simple multi-page site. I am asking for a simple example because I learn best from simple real world exam...

MySQL hierarchy data to JSON string in PHP

I have data in a MYSQL DB that looks like this: id,parentid,name,count 1,0,top,10 2,1,middle1,5 3,1,middle2,5 4,3,bottom1,3 5,3,bottom2,2 and want to output it via PHP as a heirarchical JSON string where 'top' has a collection of 'middle's etc. Get my drift? Anyone have a recursive PHP function to help? ...

How to protect downloadable files in a remote directory from non-premium users (in php?)

Im building a "premium" section of my site and Im in a need to give download access to files in a remote directly (on a different server), to users with special privileges (accounts stored in mysql db). My site is coded in php/mysql so a php solution would be great. ...

How to convert from php to MVC in codeigniter

I have the following db and php. I am tring to make a unodered list of category menu. The orginal php is working by itself. I am trying to convert this to MVC in codeigniter and the following is what I got so far and not working. If someone can point out what I am doing wrong, I will apprecitate it. Database CREATE TABLE IF NOT EXISTS ...