php

Setting A Header Image for a Wordpress Page and all its children

Wordpress. I've got a handful of pages, each with children -- varying depths. Let's say it's like this: +about -- page1 -- page2 +stuff -- page1 --- sub-sub-page -- page2 My problem: I want to set a graphic header for all the "about" pages, including all its children... and a different graphic header for all "stuff" pages and all it...

PHP: Detect invalid characters in a text

Hello! I would like to parse user inputs with PHP. I need a function which tells me if there are invalid characters in the text or not. My draft looks as follows: <?php function contains_invalid_characters($text) { for ($i = 0; $i < 3; $i++) { $text = html_entity_decode($text); // decode html entities } // loop is used ...

php_pdo.dll and php_xsl.dll

Can these two items work together? php_pdo.dll and php_xsl.dll. I have a php server and it currently hosts a couple sites - one of which requires the php_xsl.dll to work. I am trying to install Piwik, but it says it needs php_pdo.dll and php_pdo_mysql.dll - whenever I add these to the php.ini file, it crashes both the piwiki site and ...

PHP fails to setcookie

I'm a PHP virgin (first day), so please type slowly. I have a number of images, bg_001.jpg, bg_002.jpg, etc., which I want to rotate through each time the page is refreshed. I tried this: if (isset($_COOKIE["bg1"])) { $img_no = $_COOKIE["bg1"] + 1; } else { $img_no = 1; } $filename = 'bg_' . sprintf("%03d", $img_no) . '.jpg'; if (!...

mysql replacing columns in a table

I'm inserting data from a file that has 18 columns, the table that I would like to insert it into has 20 columns. 2 of those columns already contain data. How do I go about inserting the file into the table without overwriting the existing data. below is a example of the code. note $line .= ',,' is appending two columns because the upda...

datewise records sorting /fetching from large mySQL database

Hi, I have a separate table for every day's data which is basically webstats type : keywords, visits, duration, IP, sale, etc (maybe 100 bytes total per record) Each table will have around a couple of million records. What I need to do is have a web admin so that the user/admin can view reports for different date periods AND sorted by c...

PHP: 2 strings - which one is UTF-8 and which one not?

Hello! I have a database with lots of strings. Some of them are correctly UTF-8 encoded, some of them not. Therefore, I've set up a script which selects 100 strings from the db. The following function decides whether a string contains UTF-8 or not (no matter if it's correct): function detectUTF8($text) { return preg_match('%(?: ...

This REGEXP echos one thing, but enters into MySQL another. Why?

Hi, I have a query that when I test it with "echo", works well: $url = "http://search.twitter.com/search.json?q=&amp;ands=&amp;phrase=&amp;ors=&amp;nots=RT%2C+%40&amp;tag=andyasks&amp;lang=all&amp;from=amcafee&amp;to=&amp;ref=&amp;near=&amp;within=15&amp;units=mi&amp;since=&amp;until=&amp;rpp=50"; $contents = file_get_contents($url); $...

How to get commented string using regular expression in PHP?

Hi, I am trying to get commented strings in my code using regular expression in php. Let's say I have following string. $string = " ///<summary> ///test ///</summary> "; I use preg_match_all for regular expression function. when I put $string to preg_match_all, it displays Warning: preg_match() [function.preg-match]: Unkn...

Show a link with div php mysql jQuery

I have a link that says remove I have hidden the like by < div id="remove_$id" style="display:none">< /div> and then i want to be able to roll over a < tr id="$id" > and then remove comes up only for that id and when you roll off it the remove will be hidden I cant get the jquery code right for it to work Can some one help me please ...

Is there anything like hpricot or beautiful soup for php?

Possible Duplicate: Robust, Mature HTML Parser for PHP I am looking for a good way to parse and modify html documents server side in php. Beautiful soup and hpricot look like very good tools but they are not available for php. Are there any good libraries that can do this in php? Tidy appears to be partially what I am looking fo...

Passing an object to a .NET web service via PHP's SoapClient

My company publishes a set of .NET webservices available via SOAP. I need to tie my PHP application into these, but I'm bumping up against a problem that I can't find a solution for. One of the services I need to access has a signature of Advertiser CreateAdvertiser ( Advertiser advertiser ). How can I pass an instance of an object that...

Good extension/wrapper for mysqli that returns a associated array for a prepared sql statement

Can anyone recommend a good wrapper class or extension to PHP's mysqli extension that allows the equivalent of mysql->fetch_assoc() for a prepared statement. That is ideally it condenses down into a single statement the tedious complexity of the init/prepare/bind/fetch-loop. ...

A question on an example in PHP 5 in Practice

HI, I don't understand why the author of a php book used $disks = 1 in a public function __construct($disks = 1)? I tried to replace $disks = 1 with $disks only, it also worked. Why would author doing that? <?php // Define our class for Compact disks class cd { // Declare variables (properties) public $artist; public $title...

Outputting message body from eZ Components ezcMailMultipartReport object

I'm attempting to output the message body of messages retrieved from my imap server, using the ezcMailImapTransport class from eZ Components. I'm able to connect and retrieve all the messages, but I can't figure out how to output the message body. The output of print_r($mail[0]->body); is below. I just don't know how to deal with an ob...

Voting system - How to store all votes in MySQL and how to properly tally the results

I'm developing a system to allow users to vote on different subjects using a Yes / No / Maybe question set. Each question will be weighted as 2 (Yes) / 0 (No)/ 1 (Maybe) NOTE(The users will be voting multiple times, potentially huge amounts) My plan is to store the answers in a mysql db. Do I store each vote separately? (ID/Vote/) ...

Php jquery mouse over help

Now for some reason i can't get this code to work When i move the mouse over < tr id='$id'> i want the #remove_$id to be showing and then hidden when the mouse is moved off jQuery Code: $(function() { var id = this.id; $("tr").hover(function() { $("#remove_" + id).show(); }, function() { $("#remove_" + id).hide(); }); }); PH...

strange ^M at file name

[root@file Engineer]# ls resume_Al_Kassar_9-29-08.doc.txt^M resume_Al_Kassar_9-29-08.doc.txt? [root@file Engineer]# But I browse into that directory by "File Transfer Window",didn't see ^M at all it's simply "resume_Al_Kassar_9-29-08.doc.txt" Any anyone step into this issue ever?And how to solve this? This .txt^M file is generated ...

Wamp PHP CLI

I'm running wampserver and can't seem to use php files in the CLI. Supposedly there are two modes of running php, CGI and CLI. I can't figure out how to enable CLI since I don't see php-cli.exe in /wamp/bin/php/php5.2.6. When I try and execute php scripts they wont run. Does anyone know how to get the CLI running php scripts using wam...

how to write unified new line in PHP?

Obviously it's not "\r\n",which only fits windows,and will cause ^M on linux ...