php

What is the usage of ":" in if and else statements?

I saw the following code snippet: <?php if(!empty($_POST)): // case I: what is the usage of the : if(isset($_POST['num']) && $_POST['num'] != ''): $num = (int)$_POST['num']; .... if($rows == 0): echo 'No'; else: // case II: what is usage of : echo $rows.'Yes'; endif; I would like to know what the usage of ":" in php code is. ...

How should I handle when a friend ignores someone in a PHP/MySQL app?

I have a table like friends(friendship_id, fid1, fid2, ENUM('pending', 'accepted', 'ignored'). When a user ignores someone's friend request, I want to make sure that they don't get a message saying, "You've been ignored!", but I also want that data logged. Any suggestions on how to approach this? ...

URL Rewriting - PHP + Apache

I wanna turn PHP dynamic URLs into static URLs. For example, I want URLs like http://www.example.com/book.php?title=twilight to become http://www.example.com/book/twilight and http://www.example.com/writer.php?name=meyers to become http://www.example.com/writer/meyers When it's done, will my form validation on the site change? My URL...

modifying xml document using php

hello everyone , i have an xml file "Machine.xml" it contains: <Parameter name="host" value="localhost"/> <Parameter name="port" value="5900"/> i would like to change both parameters values using a php script... how can i do that? i mean i want the script to change host's value for example to : value="7.3.4.5" and port value to...

mysql_num_fields(): supplied argument is not a valid MySQL result resource

Happy Friday All, I'm working on a custom CMS, made changes to the DB schema and presentation layer. I'm getting an error relative to mysql_num_fields and mysql_num_rows using the following section of code. Can someone give me an idea of why these errors are being raised? Thanks, Sid public function viewTableData($db_name,$table_nam...

PHP Arrays, displaying fruits like 1.apple 2.banana, etc

I have some array: array 0 => string 'Apple' 1 => string 'banana' 2 => string 'Nanas' 3 => string 'Grape' What is the best way to display 1. Apple 2. banana 3. Nanas 4. Grape Any Ideas? ...

Most affordable, portable, battery-powered hardware for running a LAMP setup for development?

I will be flying to Australia (~15 hr. flight) and I'd like to continue work on my current project while on the airplane. My project (website on CakePHP framework) requires a LAMP bundle so I'm looking for a very portable, reasonably affordable device that can accommodate a LAMP installation, and also could retain battery life througho...

Problem in XML content..?

Okay. Here's the code. XML Parsing Error: not well-formed <item_to_page_title><![CDATA[Breaking news, real-time scores and daily analysis from Sports Illustrated SI.com]]></item_to_page_title> The error tracking line thing points to the []-like char as the problem. I've set the page to UTF-8 and still it doesn't work. No, I can't j...

Encoding troubles - one format to another

I have a scraper that is collecting some data from elsewhere that I have no control over. The source data does all sorts of interesting Unicode characters but it converts them to a pretty unhelpful format, so \u00e4 for a small 'a' with umlaut (sans the double quotes that I think are supposed to be there)*. of course this gets render...

Sending Email to Multiple Recipients from MySql Recordset

I want to send an email to multiple recipients using PHP mail() function. The email message is simply a reminder that a membership is due to expire so email addresses will come from MySql database query. There would anywhere from 2-10 at any given time. I found the following code but it generate errors. The problem is not with my que...

How can I capture the PID and output of a backgrounded PHP process at the same time?

I have one PHP script that has to start a second script in the background using exec. The parent script needs to capture the PID of this new process, but I also need to capture any potential output of the child script so it can be logged in the database. I can't just have the child script log to the database because I also need to captur...

What is the right way : url query or openning session?

I have a search form for check avaiable rooms beteen two days. After search.php, I have listed available rooms. I want to get checkin and checkout dates for reservation. What is the right way? 1-urlquery : <a href="rooms.php?roomID='. $value['room'].'&in='.$checkin.'&out='.$checkin.'"> 2- open session for checkin and checkout Thanks...

php within x seconds of y time

How can I make a script that can check wether it is currently x seconds from 12am or 12pm? thanks ...

How to get the tag "<yweather:condition>" from Yahoo Weather RSS in PHP??

Guys, i have this script: <?php $doc = new DOMDocument(); $doc->load('http://weather.yahooapis.com/forecastrss?p=VEXX0024&amp;u=c'); $channel = $doc->getElementsByTagName("channel"); foreach($channel as $chnl) { $item = $chnl->getElementsByTagName("item"); foreach($item as $itemgotten) { $describe = $itemgotten->getElementsByTagName("de...

Simple XML parsing on PHP

Guys i have a xml file who contain this info: <?xml version="1.0" encoding="utf-8"?> <ES> <clima code="0" value="Tornado" /> <clima code="1" value="Tormenta tropical" /> <clima code="2" value="Huracan" /> <clima code="3" value="Tormentas severas" /> <clima code="4" value="Tormentas eléctricas" /> <clima code="5" ...

searching for a free and trusty js and php code review tool

hi, i'm looking for a free tool, which i can use local to do javascript and php codreviewing. if it's even easy to install you'll be my hero! any experiences, preferences, suggestions, commendations? thanks in advice. p.s.: if there is no adequate tool which can handle both good enough, i will be happy with a combination of two tools...

Nusoap not throwing exception when my Webservice is down!

I have a Php application running on my "Server A" that consumes a .NET Web Service hosted on my "Server B". For some reason sometimes the IIS on my "B Server" fails to response and on my Php web application takes exactly 60 seconds to load the page where the webservice call is. I want to be able to change those 60 seconds because is too ...

setcookie problem IE8

Hi, I cannot get setcookie to work with IE8. My script works fine in IE7, firefow and Safari, but it doesn't seem to work in IE8 running on Windows7 and I'm getting desperate! I'm using a very short small test script now: <?php $value = 'content'; setcookie("CookieTest", $value, 0); ?> With Firefox this works fine, the cookie is bei...

soap headers problem

I've been trying to use code below to test web service but it didn't seem to work. I keep getting exception saying SoapFault exception: [soap:Client] System.Web.Services.Protocols.SoapHeaderException: eWAYCustomerID, Username and Password are required in soap header at ... As I am very new to soap I'm guessing its something simple I ...

How to "pass" class attribute to a class method?

How can I "pass" eventName to dbSafe() in the following fashion? Is this possible? What would dbSafe() look like? $eventClass->eventName->dbSafe(); I'm guessing dbSafe() would look roughly like this: public function dbSafe() { return mysql_real_escape_string($this); } ...