php

PHP Sockets, any way to speed this up

I'm writing a small script to see if certain ports on certain devices are in use or are open. My code is: for($c=1;$c<=16;$c++){ echo "<tr><td>Pod " . $c . "</td>"; for ($d=5000;$d<=5010;$d++){ $tmp=fsockopen("10.0.0." . $c,$d,$erstr, $errno, 1); if($tmp){ echo "<td class='o'>OPEN</td>"; fclose($tmp); } e...

Accessing a class object in PHP

Does anyone has idea how to access HREF from the below object: SimpleXMLElement Object (    [@attributes] => Array        (            [title] => Preview            [rel] => enclosure            [type] => image/jpeg            [href] => http://a1.phobos.apple.com/us/r1000/008/Purple/94/ee/38/mzl.fupornmt.320x480-75.jpg        ) ...

Should i learn php 5 or php 6?

I'm not sure how popular php 6 is and if many webhost even support it, so basically learn php 5 first or just straight to php 6? Thanks in advance. ...

PDO MySQL call retruns unbuffered queries error

I have researched online but most examples or instructions don't seem to apply to what I am trying to accomplish. In short my code should accomplish the following: A stored procedure is called from my php script which returns a dataset I want to loop through and produce rows in a table (for online display purposes). One of the fields ...

Search mysql using multiple variable from multiple tables

I'm using php with mysql Hello I have a couple of tables with information about books. One table is like this id, bookTitle, BookText The other is like this id, bookid, amountofsales I would like to search the text of the book, and the book title from one table, but also be able to include amountofsales from the other table to give...

is_dir and if else outputting syntax error, unexpected T_ELSEIF

Hello everyone, I am having some trouble with an if, else and is_dir; I am trying to create a small script that tells me if the input is a folder or a file, I have looked at: http://us2.php.net/manual/en/function.is-dir.php for a few examples, and none of them seemed to resemble mine, I read a bit on if and else as well, and it looks li...

Relation between classes

My system has an User class with a lot of properties: name, e-mail, address, phone number, etc. And it has also an UserAccount class with properties: username, password and salt. This is a blog application. UserAccount provides login and logout methods. Now I don't know who will be related with Posts. Should an User contains posts or an ...

Change base href in PHP included file

Hi, I have a header file which has the html <head> tag in it. I'm trying to set the <base href="/mysite/"> in this file, but when I include it (such as into my index.php file), it doesn't actually change my base href. Any absolute URLs in index.php (e.g. /css/style.css) try to load from host/css/style.css rather than hosthost/mysite/css...

Share a Kohana install between sites.

Hey all, kind of new at Kohana and I have a quick question. I have a site where there will be three subsections, organized by subdomain (i.e. admin.site.com, community.site.com, www.site.com) but each of the subsections will be pulling from the same database so should be sharing the same models. Is there a way to organize it so that I c...

webinar recordings aggregator site / feeds?

Conferences are expensive, but thanks to the kind community, many of the videos are recorded and made available online afterwards. They are amazing way to learn the latest and the greatest but they are sometimes hard to find. Where do you find the latest recorded online seminars? Are there any webinar aggregator site / feeds? ...

How can I validate the structure of my PHP arrays?

Is there a function out there to make sure that any given array conforms to a particular structure? What I mean is that is has particular key names, perhaps particular types for values, and whatever nested structure. Right now I have a place where I want to make sure that the array getting past has certain keys, a couple holding a cert...

Parsing text in MVC

You have a blog. You want certain combinations of symbols (i.e. :), :(, :p ...) to be parsed into emoticons before the post in the blog are printed on the screen. Should this parsing be a responsibility of the Model, the View or the Controller? ...

jqGrid for PHP Custom function using Editrules

Hi Guys, I am also quite a newby to jqGrid and need some help please. I need custom validation on a field I am editing. I looked at the examples and tried the following code below but get the error "Custom function should be present in case of custom checking!". Please help a newbie out!!! <?php $grid->SelectCommand = 'SELECT * FROM sm...

PHP Regular expression

I need to add href=" before an http:// if this http:// doesn't follow href=" or src=" Following code partly works. Partly means it considers <a href=" only but not src=" $str= preg_replace( "/(?<!a href=\")((http|ftp)+(s)?:\/\/[^<>\s]+)/i", "<a href=\"\\0\"> target=\"blank\">\\0</a>", $str ); Thank you guys in advance ...

Execute multiple insert, update, queries separated by ";" at once!

I use remote server to store values into MySQL database. I don't use any SELECT queries, only INSERT, DELETE and UPDATE. When I execute 70,000 queries I have trouble with speed. I was trying mysql_unbuffered_query and I saw little performance profit but it's still too slow. I remember that some functions in PHP allow me to execute se...

How do I use the page URL as a form variable?

I'm trying to use the page URL as a variable inside a form submission so that I can write it into my database and figure out what pages are getting more list sign-ups. Is there any easy way to do this? ...

php development on a Mac, I have nginx already installed, what else do I need?

I have nginx installed (was using it for Ruby on rails with passenger). What do I need to get this to work for PHP now? ...

MySQL - How to select rows where value is in array?

Ok, normally I know you would do something like this is you knew the array vals: SELECT * WHERE id IN (1,2,3) But... I don't know the array vals, I just know the value I want to find in a 'stored' array: SELECT * WHERE 3 IN (ids) // Where ids is stored as 1,2,3 Which doesn't work. Is there another way to do this? Thanks. PHP + MySQ...

How do I iterate through this loop Get each Item Separately

I have this array I want to get the Values "ABC" ,"1","2" and so on respectively and store them in separate variables. I have used nested foreach but could not get it array(2) { [0] => array(3) { [0] => string(10) "ABC" [1] => string(1) "1" [2] => string(2) "2" } [1] => array(3) { ...

Selenium, xpath to match a table row containing multiple elements

I'm trying to find a Selenium/PHP XPath for matching a table row that contains multiple elements (text, and form elements) example: <table class="foo"> <tr> <td>Car</td><td>123</td><td><input type="submit" name="s1" value="go"></td> </tr> </table> This works for a single text element: $this->isElementPresent( "//table/tbody/...