i have this php algorithm ranking function(hacker news),
function calculate_score($votes, $item_hour_age, $gravity=1.8){
return ($votes - 1) / pow(($item_hour_age+2), $gravity);
}
and i have this table in mysql:
post{id, post_text, votes, date}:
i was wondering how i can pass these mysql data paramters to that function, to det...
Hello,
I am trying to capture the following content in PHP using regular expressions:
/*
Name: Test
Description: my test
*/
I have tried the code from here: http://stackoverflow.com/questions/287991/match-everything-inbetween-two-tags-with-regular-expressions but it doesnt capture the new lines.
EDIT: I used the ...
Using PHP/SimpleTest, I want to test if a method calls a static method of another class. Can this be done with a mock class?
...
Anyone has a PHP function that can grab all links inside a specific DIV on a remote site? So usage might be:
$links = grab_links($url,$divname);
And return an array I can use. Grabbing links I can figure out but not sure how to make it only do it within a specific div.
Thanks!
Scott
...
I Can't normal open my page show me all but without css when i refreash work fine ? thx
...
Shortly i decided to go for the Dependency Injection technique for a new PHP application i am about to write.
However, I am not entirely sure i understand it enough. My problem is, the baseClass has a dependency on various items, while a lot of different classes will need to extend it. For example:
namespace system;
class baseClass
{...
I'm trying to connect to a Sage Timberline Accounting database on my Windows 2003 Server using php 5.3. I have php correctly installed with IIS as fastcgi. I have a system DSN setup in ODBC Manager and correctly configured for the Timberline database. Here is my php script.
$conn = odbc_connect("Timberline ODBC","user", "password");
...
I have an array as following. I order that array by the value of the key "attack". Everything is ok until then, but I want to get for example only 9 of that total attack values are summed up: I want to sum up 3 of key1 (3 * 45), 4 of key3 (4 * 35) and 2 of key2 (2* 25) are automatically summed up. I would be greatly appreciated if somebo...
hi, how do you call php function that is in a different file from a javascript function.
I have a javascript function that recieves a variable frm an onclick function. The varaible is an id that I will use to retrieve data from mysql database. The variable is then pass on to php function that will access the database to get the data an...
Our client wants us to create larger videos from UGC videos specifically submitted to the client. So, I am looking for either a server side approach or a client side approach where
Users will upload their video to any well-known video sharing site (YouTube/Vimeo etc) and give us permission to stitch it together.
We can either make one...
I start to create a PNG thumbnail by using this function:
$image = imagecreatefrompng("http://imagenic.net/images/pfujz9j5juav1qrex00.png");
However, it says:
'http://imagenic.net/images/pfujz9j5juav1qrex00.png' is not a valid PNG file
It works OK with other PNG images, so I guess something is wrong with this specific picture.
Wha...
Before I probably reinvent the wheel, can anyone tell me if there exists a FOSS code library to check email on a regular basis (or driven by a cron job), to parse the title and body and to perform certain functions (mainly sending other emails).
I was thinking PHP as it is server side and good at string handling, but I would be happy en...
Hi
Can you please tell me why this works:
$customer_data_date14daysAgo = mysql_query("SELECT COUNT(*) AS count
FROM tableName WHERE datetime BETWEEN '$date14daysAgo%' and
'$dateToday%' ") or die(mysql_error());
But this doesn't?
$customer_data_date30daysAgo = mysql_query("SELECT COUNT(*) AS count
FROM tableName WHERE datetime BE...
i want to query blog posts from the database created in the last 3 hours,
table
blogs{id,blog_text,date}
date format: datetime
...
Hi,
I'm wondering if this could be achieved.
I know how to get the top 10 from my database using SQL. But I would like to take it a step further.
My idea is to update the DIV every couple of seconds. First the script will check if there are any updates in the database, if so the DIV should be updated. I can do this on my own, but my ...
I have a products listing page that lists 3 products in a single line per page.
So I want to put next-previous buttons on left-right side of this 3 products line.
So when someone click next, it bring next 3 products by slide-in effect.
Any suggestion ?
...
Here's what the class loader looks like:
loader.php
class Load
{
public static function init($class)
{
require_once 'classes/' . $class . '.php';
return new $class();
}
}
$class = Load::init('MyClass');
The error being returned is:
Fatal error: Class 'MyClass' not found in /www/website/application/model...
I'm not sure what I'm doing wrong, but with MongoDB and PHP i'm trying to do this:
$db->textures->remove(array("_id"=>$_GET['texture_id']),array("safe" => true))
But nothing happens. I did a print_r and it says:
Array ( [err] => [n] => 0 [ok] => 1 )
...
I have a web service running written in PHP-MYSQL. The script involves fetching data from other websites like wikipedia,google etc. The average execution time for a script is 5 secs(Currently running on 1 server). Now I have been asked to scale the system to handle 60requests/second. Which of the approach should I follow.
-Split function...
I use imagecreatefromjpeg, imagecreatefromgif, and imagecreatefrompng functions to create thumbnails of image/jpeg, image/gif, and image/png mimes.
I would like also to create thumbnails of .BMP files.
I checked one file and found out that its mime is image/x-ms-bmp.
However, I cannot find an appropriate imagecreatefrom... function.
...