php

php string operation

i have the following code in html <? foreach($tst as $test) : ?> <?=$test->id?>, <? endforeach ?> and that will result as test1,test2,test3, how avoid that last comma in simple method . I cant use complicated code in html like <? $i = 0 ;?> <? foreach($tst as $test) : ?> <?=$test->id?>, <? endforeach ?> <? $i++ ;?> <? if($i != co...

PHP Framework recommendation?

Hi, I'm pretty much new to PHP and still learning as I go. (aren't we all) I'm working on a Web 2.0 startup and I wonder what PHP Framework should I use. It must be free and of course enables commercial use, supports AJAX, DB, etc. And I would prefer that it didn't force JSON when using AJAX, I think XML is better... I don't know :) W...

Advice on framework design

Hello, i'm currently constructing some kind of mini-framework for a project, and come up with this solution. I have tried many of them, but this seems to me very convinient (code is shortened for simplicity): # Basically it's just a Registry pattern class Repository { private static $objects = array(); public fu...

PHP Associative Array Strucuture

Is there any thing wrong with this array? $selects = array( "getmoney1" => $money["Dimes"], "getmoney2" => $money["Nickels"], "getmoney3" => $money["Quarters"] ); I am learning, and I want to know more, and how to do it right. ...

SELECT * in SQLite doesn't return everything in the table

I'm using PHP to fetch data from a database. Here is the code: <?php $db = new SQLiteDatabase("testDB.db"); $query = $db->query("SELECT * FROM blog ORDER BY blogdate DESC"); while($entry = $query->fetch(SQLITE_ASSOC)) { //only one blog entry per day echo "<a href=\"display.php?date=".$entry['blogdate']."\">".$ent...

Passing custom variables to paypal IPN

Hi, I am trying to pass custom variables to paypal IPN. I can manage to pass one variable. But i don't know how to pass multiple variables. My Process is something like this User fill up the form They click button and it goes to paypal They paid, IPN send me back the information and that ipn.php added variables that passed to the dat...

Get meta information, title and all images of any webpage using php

Hi Friends, I want to get all the meta information like description, title, keyword etc of any web page using php. I am using *get_meta_tags* php function but its displaying warning. I have paste the error below. Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is kn...

Time of day script

Hi all, I have a small script that depending on the time and day; I would like it to output different things: <?php $currenttime = ((date("H")+7). ":" .date("i")); if ($currenttime >= "16:30") { $tomorrow = mktime(0, 0, 0, date("m") , date("d")+2, date("Y")); $jsdate = (date("Y"). "-" .date("m"). "-" .(date("d")+1). ...

PHP image creation from hex values in database

I've got the code below to pull hex values from a database and create an image of that colour. There's over a thousand values, so it's looping to create an image for them all. It seems to work fine except it just keeps overwriting the first image (0.jpg) instead of creating new ones 0.jpg, 1.jpg 2.jpg etc. Any idea where I'm going wrong?...

How To Store Tags In A Database Using MySQL and PHP?

I wanted to create a database that will store the tags that users enter for there questions and then display them all for each individual question posted something like here on SO. Here is the table that does everything for me know. CREATE TABLE questions_tags ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, url TEXT NOT NULL, tag VARCHAR(25...

Solar PHP framework

We are currently looking joining an open source PHP farmework project instead of continuing to work on our own PHP MVC code. Likely candidates are Yii and Solar, because they appeal to our own coding style, have tackled issues that we feel need tackling. I realize there are plenty of PHP frameowrk related questions on SO already. Howeve...

Are PayPal cookies linked to an IP address?

I have been experimenting with curl for accessing the PayPal payment authorisation site using PHP. e.g. ... $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp); curl_setopt($ch, CURLOPT...

MYSQL IF(expr1,expr2,expr3) but I don’t want any expr3 (if expr3 then don’t output anything.

As the title says, I just want an output if the if is matched, if it’s not matched then I don’t want any output. I currently have this, but it gives an error obviously ...rFormat=IF(ISNULL(rFormat), VALUES(rFormat),UNCHANGED)… I looked around http://dev.mysql.com/doc/refman/5.4/en/control-flow-functions.html but didn’t really find ou...

Swapping a string where space is found in php

Hi, I need to implement the following functionality: I have a name field which contains both name and surname. This is stored in a database and is in the order 'surname name'. I am implementing a script which searches through these records. Currently, I managed to check if a string contains a space, if it contains a space it means it ...

Select surrounding rows php/mysql

I want to select a group of rows around a row matched on conditions, ie select a row and then return 5 records before and after it. More info as requested (sorry bout that!) Ok, so the table records lap times from a race. Laps are related to Users (users have many laps). I want to find the best lap time for a User then x number of best...

How to grab live text from a URL?

Im trying to grab all data(text) coming from a URL which is constantly sending text, I tried using PHP but that would mean having the script running the whole time which it isn’t really made for (I think). So I ended up using a BASH script. At the moment I use wget (I couldn’t get CURL to output the text to a file) wget --tries=0 --ret...

php htmlspecialchars and utf-8

I am just trying to confirm something with htmlspecialchars I have just converted my database into UTF-8 and I think I finally have it all working, but throughout my code i have used the php htmlspecialchars function htmlspecialchars($val, ENT_QUOTES,'ISO-8859-1',false); Do I need to worry about changing all the entries to : htmlspec...

PHP - Calling a static function from an extended class

Hi, Let's say I have three classes set up as follows: abstract Class A { public static function testfunction() { print_r('Hi'); } } Class B extends A { } Class C extends A { } If I call testfunction through class B or C ie B::testfunction(); Is there a way of printing out the name of the class that called it? So for examp...

Php - Insert Autoincrement Value - For Parent/Child Tables - Concurrency Problem

Consider a simple schema of one to many relationship. Parent Table's Id is referenced in the Child table. In php I want to insert a row into the table using the statement mysql_query($query). Then I will get the id of the last inserted row by using mysql_insert_id(). Then i will use this id to insert the another row into the child's tab...

How do I obtain the path to an image when writing a MediaWiki extension?

I'm trying to write a simple extension for MediaWiki but I can't anywhere find in simple terms, how to call functions within the application to give me the 'hashed' path to an uploaded file. I've tried the following function call which some searching indicated would return the path but it results in an undefined function error. //$inpu...