php

Walking through html searching for first level blocks

In addition to my other question about the analyzing of html, and searching for <p> and <ul>/<ol> tags this question. $in = '<p>Bit\'s of text</p><p>another paragraph</p><ol><li>item1</li><li>item2</li></ol><p>paragraph</p>'; function geefParagrafen($in){ $dom = new domDocument; $dom->loadHTML($in); $x = $dom->documentElement; } ...

Use preg_match to find if string contains script-tags

Hello, How do I write a pattern to use with PHP's preg_match function to check if a string containing script-tags? ...

php not updating session variables?

Ive been working with the twitter oauth and api and im having a weird issue. What im doing is generating a request link, saving the request token and secret in a session variable, then when the user comes back from twitter, trying to retrieve those keys to store them in the database. When i execute the following: session_start(); $to ...

How to get PHP command line to work with PDO?

I want to work with PDO, through PHP command line. It works perfect through the PHP web API, but not through the command line. But when I execute the command: php test.php, it says unknown class PDO. I think it has something to do with the thread-safety difference. Because, when I execute the above command, the following warnings come:...

How do I do a strtr on UTF-8 in PHP?

I'm looking for a UTF-8 compatible strtr for PHP. ...

Drupal State Machines, usage and alternatives

Do "State Machines" used in Workflow-NG module (D5) have any visual interface (in node form or whatever)? Or they are totally internal entities that I can only set and evaluate? The initial objective behind question was to send emails based on changed node status (taxonomy based). If these State Machines are cumbersome, I can probably ...

How to make this PHP snippet work without warning?

The code is short,but complete: function process($obj) { if(empty($obj))return 1; return 2; } echo process($arr['nosuchkey']); As we all know, calling empty($arr['nosuchkey']) will never report warnings. But process($arr['nosuchkey']) will report a notice. Is there a workaround without disabling warnings; say, by syntax? ...

about html textarea's post value

text file in window, each line end with \r\n, in unix, each line end with \n. Does textarea's post value follow this rule? ...

Detect additional text on url

I have php condition basically static if the page is "biz-los-angeles.php" show specific html. I would like to add another condition for example "retail-biz-los-angeles.php". What would be the easiest way to do this. Basically i just want to script to pick up "retail" text at the beginning of the url and return specific html. Below is t...

How to select data from a table where the table name has blank spaces in?

I have a situation, I have a mySql table named 'Master File' with contains 6000 records. Howver I get an error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource My code looks as below. $sql = "SELECT * FROM Master File"; $results = mysql_query($sql); //Looping threw the Master File while($row = my...

XPath - select child of $var

Hello there, I'm trying to print all the <title> and <description> elements of an RSS 2.0 feed in a list using PHP. I could simply get these elements using: $rss->xpath('rss/channel/item/title | rss/channel/item/description') but I want to use it a little different. I want to use PHP to iterate through all the <item> elements using a f...

How declare WSDL for PHP function that returns multiple TYPES?

Hi, I'm writing a PHP web service and one function. I want to set up a web service in PHP. I need to generate the WSDL description for this web service so it's accessible from I.e. visual studio. It takes documents / search strings as inputs and recommends similar documents as output. I return an array with a first element resultCode...

php file uploading and storing

I want to upload a file on my PHP server. I am currently able to upload it on server using the following code but I don't know how I can store it on the server. How can I store the file in a specific directory? I also want the users to be able to download the files but only once they log in not before that. For example i store the fil...

How to parse an XML tree with DOMDocument ?

Hi, Here is my XML file : <?xml version="1.0" encoding="utf-8"?> <root> <category> <name>Category</name> <desc>Category</desc> <category> <name>Subcategory</name> <desc>Sub-category</desc> <category> <name>Subcategory</name> <des...

Create a page without placing .php at the end?

I was looking for ways to mimic something I've seen, however I'm really not even sure where to start or how to search for it. Lets say my page was: foo.com/ and my index page could take an argument of: index.php?id=5 What I'm wanting to do is create the following: foo.com/5/ rather than placing index.php?id=5 just use the webstring t...

How can I cycle through hex color codes in PHP?

I want an array where each field in the array contains a color code array(0 => '#4CFF00', 1 => '#FFE97F') And I want this to go through the whole spectrum of colors starting from green to black. green-> blue -> dark blue -> purple -> yellow -> orange -> red -> brown ->black This order doesn't need to be exactly the same, but I thin...

no quirks mode on php pages?

My site is all php pages, since it's all database stuff. However, I'm having trouble putting the pages into no quirks mode... I did the regular thing: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; and this do...

How can I extract the title from an encrypted PDF in PHP?

How can I extract the title from an encrypted (write protected, not password protected) PDF file using PHP on Linux? Usage of external libraries or binaries are OK. Zen_PDF did not work (Exception: Encrypted document modification is not supported) nor did libextract (title="filename of pdf.pdf") ...

Warning: mysql_connect(): Access denied for user '‎‎u1' ?

This is extremely basic and I apologize for asking such a rookie question. But I a getting this error: Warning: mysql_connect(): Access denied for user '‎‎u1'@'172.16.3.139' (using password: YES) in /usr/local/pem/vhosts/103503/webspace/httpdocs/eirestudio-tools/crm/add-contact.php on line 53 The user says ‎‎u1? What does ...

get server ram with php

Hi, Is there a way to know the avaliable ram in a server (linux distro) with php (widthout using linux commands)? edit: sorry, the objective is to be aware of the ram available in the server / virtual machine, for the particular server (even if that memory is shared). ...