php

PHP code on orbited comet server

Where can I find the PHP sample code for orbited comet server v0.7? I think that I have to build another server together with orbited server in order to support the comet function. Am I right? If so, how can I build up that server? ...

PHP/Joomla When to use references

i am reading http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_3_-_Using_the_Database $db = when do i need to use references? i tried the same thing without reference and it works. i thought objects are passed by reference (probably assignment also)? if i assign by "copy" will there be any difference? maybe dro...

insert data to the database, and then get an autogenerated int key in return

Hi. Couldn't find a method like the int executeUpdate(String sql, int autoGeneratedKeys) in php. I want to insert data to the database, and then get an autogenerated int key in return (the ID). Thanks :) Oh, and PS: it has to be a method from the mysqli class =) ...

Strip HTML tags and its contents

I'm using DOM to parse string. I need function that strips span tags and its contents. For example, if I have: This is some text that contains photo. <span class='title'> photobyile</span> I would like function to return This is some text that contains photo. This is what I tried: $dom = new domDocument; $dom->loadHTML($st...

PHP: Count Number of Arrays in SESSION

I am storing shopping cart data in a SESSION Array like this: $_SESSION['cart'][$sessID] = array ('quantity' => 1, 'price' => $prodPrice, 'prodName' => $prodName, 'size' => $size, 'handle' => $handle) Each time a user adds an item to the cart, a new sessID is created and a new Session Array. How do I count how many sessID's there are...

WordPress: How can I add extra classes via variables when using body_class()?

Hi, I am trying to add some dynamically (based on the URI) created class names into the standard body_class() statement. The wordpress codex mentions to put the class into the brackets while using the body_class('add-class-here') however I have 2 variables that I need to echo out inside the body class="" so I tried doing it as follows...

How to make my own while Loop just like Wordpress Loop?

Hi all programmer... im new here and new in PHP too.. Just wondering how to make my own flexible loop just like in Wordpress... Note im not talking about wordpress.. I want to implement it on myown PHP application... let's look back in WP, there is a code something like this: while (have_post() : thepost())// .. bla bla... echo the_t...

How to get the parameter value of the currently active component in Joomla

I'm creating a custom template, and i have added a parameter 'headerpic' to various views. <param name="headerpic" type="filelist" default="" label="Header Image" description="Select the image for the header" directory="images/headers" filter="\.jpg" /> The client can then change the header image for each page from a drop down list. ...

PHP OOP and AJAX: How to handle serverside in Class?

Hey I'm working on converting my standard PHP project to OOP but I ran into a wall about how to handle AJAX calls with PHP Classes. I'm not happy with the way I'm doing this now. I have a TillAjax.php file which I call from my TillUI.php file from a AJAX call. In the TillAjax.php file I do this to get the information passed from the aj...

How long will my session last?

Hi, Can someone please tell me how long my session will last from the data below? - I'm not sure which one tells me session.auto_start Off Off session.bug_compat_42 Off Off session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_ht...

How do I create a function which puts a unique entry in the sql table or loop?

I basically want to create a unique login varchar in a table based of a first and last name. So Jo Blob signs up and we go: // check to see if username 'JoBlob' exists.... SELECT * FROM special_users WHERE username = $names[0] . $names[1] // if it doesn't exist INSERT INTO special_users username= $names[0] . $names[1] // BUT...

Why does php DOM parsing affect charset?

$dom = new DOMDocument(); $dom->loadHTML($string); $dom->preserveWhiteSpace = false; $elements = $dom->getElementsByTagName('span'); $spans = array(); foreach($elements as $span) { $spans[] = $span; } foreach($spans as $span) { $span->parentNode->removeChild($span); } return $dom->saveHTML(); //return $string; When I use this code t...

Live FOREX data for PHP

I am building an application where I need live FOREX(currency data). I could take it from yahoo's page, by loading the html into PHP and the get then extract the data. But I do not like doing that way. Therefore I would like to ask if any of you know any other free forex resources that can be loaded into PHP? ...

Can I serve MP3 files with PHP?

In the same way that it's possible to serve up images with php, for use in CAPTACHAS and such, is it possible to do the same with audio files? I've tried this <?php $track = "sometrack.mp3"; if(file_exists($track)) { header('Content-type: audio/mpeg'); header('Content-length: ' . filesize($track)); header('Content-Disposition: filena...

Detect when link is clicked, open in new frame

I would like to create a basic URL rewrite using frames. I don't have access to .htaccess to do mod_rewrite. Is there a way using PHP, jQuery, JavaScript etc. to detect which URL has been clicked on and then open URL in new frame? Ex: user clicks on /index.php?12345 it will open in framed window /pages/12345/index.html and if they cl...

How to add MySQL support for PHP using MacPorts?

I installed php 5.3 through MacPorts and now i tried to connect to a database (MySQL) but always when i'm trying to call mysql_connect(); im getting an error: Call to undefined function mysql_connect() My setup is: Leopard 10.5.7 Installed and active packages via Macports that may be related to this problem: php5 @5.3.0_2+apache...

Multi-dimentional array question: Where does ['children'] come from?

I am confused about multi-dimentional array. In the following db, php and html, I don't understand the usage of foreach ($navlist as $key => $list){ foreach ($list as $topkey => $toplist){.. and foreach ($toplist['children'] as $subkey => $subname){... And also this code is confusing for me. Is ['children'] php? $data[0][$row->p...

Setting up apache to serve PHP when an MP3 file is requested

I'm working on a way to serve up MP3 files through PHP and after some help form the SO massive, I got it working here However, that example doesn't appear to work when I use it as the source in an audio tag like this <html> <head> <title>Audio Tag Experiment</title> </head> <body> <audio id='audio-element' src="mu...

I'm having trouble parsing a facebook feed using simplexml

http://www.facebook.com/feeds/share_posts.php?id=207302593&amp;viewer=207302593&amp;key=d95b2de790&amp;format=rss20 The link above is the URL to my shared posts on Facebook. When I load that URL in to simplexml_load_file() it provides an entire page of errors. Looking at the errors, it looks like Facebook is spitting out HTML instead of...

problem executing php file with javascript

Hi all, i have been learning about javascript and using dojo. I am trying to execute a php file with dojo. My code is dojo.xhrGet({ url: 'helloworld.php', load: testCallback, error: testError, content: {name: dojo.byId('name').value} }); for the dojo function. The php file is basically a simple script that prints the val...