Hi there,
I have two dates in mysql,
I can get the difference(in seconds) by doing date1 - date2.
Now I need to show
x days, x hours, x minutes, x seconds
If there are 0 days then it will simply be x hours, x minutes, x seconds.
So,
What is the best way to do this?
note: 3650 seconds will show as
1 hour, 0 minutes, 50 seconds.
...
This should be simpler. What do I need to define what should happen in place of a 404 error?
...
I'm working on making my script mesh with OAuth instead of Basic Auth, and I'm stuck. So far, I'm just working on authenticating at the moment, but I can't get that working. This code:
<?php
include 'config.php';
include 'twitteroauth/twitteroauth.php';
// Use config.php credentials
$conn = new TwitterOAuth(CONSUMER_KEY,CONSUM...
How to check permissions of directory in PHP
$filename = 'dev\permis';
$handle = fopen($filename.'\file.txt', "w");
if (is_writable($filename))
{
echo 'The directory is writeable';
}
else
{
echo 'The directory is not writable';
}
when i set permisson for permis folder is write ,
the file.txt is created and browser " The di...
I have people inserting video code to be displayed on my website. I want to make sure those videos dimensions don't go over 590 pixels in width.
So for example it they insert a video that's 640 x 385 my script would figure out some new dimensions so that it is only 590 pixels in width (e.g: 590 x 366)... I've got all the maths and rati...
I'm looking for a better way to generate dynamic html from php.
Before I would do something like this:
//generate.php
for(...)
{
$markup .= '<a id="'.$i.'">link'.$i.'</a>';
}
This is really ugly, and I would much prefer not to have to define my markup inline in php strings.
I am looking for the functionality of include "markup.p...
I have created different node forms for different content types, by using this function in my template:
function mytheme_theme($existing, $type, $theme, $path) {
return array(
'type1_form' => array(
'arguments' => array('form' => NULL),
'template' => 'type1_form'
),
'type2_form' => array(
'argument...
Hi there,
So i have a query that looks like this:
SELECT col1, col2, col3 ...
FROM action_6_members m
LEFT JOIN action_6_5pts f ON f.member_id = m.id
LEFT JOIN action_6_10pts t ON t.member_id = m.id
LEFT JOIN action_6_weekly w ON w.member_id = m.id
WHERE `draw_id` = '1' ORDER BY m.id DESC LIMIT 0, 20;
now this is doing a massive join...
I know that Youtube and Wikipedia was developed with PHP.
However, i wonder if the coders used a framework?
Or did they write it from scratch?
...
Im designing a MVC framework but I dont know where should I put my utility classes. I read somewhere where it said utility classes are Model Classes. Is this line of thinking correct or are they some separate type of class?
...
I normally use this function to sanitize my form inputs before storing them into my database:
//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
...
I need to get values in the url as it is
ex:
http://www.example.com/index?url=1+LY2ePh1pjX4tjZ4+GS393Y2pjd16Cbq63T3tbfzMzd16CarA==
but vriable url give me value of "1 LY2ePh1pjX4tjZ4 GS393Y2pjd16Cbq63T3tbfzMzd16CarA=="
Even though i have expected "1+LY2ePh1pjX4tjZ4+GS393Y2pjd16Cbq63T3tbfzMzd16CarA=="
any one can help me for this o...
I was wondering if some one enters a tag like ruby on rails is there a way I can add a hyphen to the white spaces between the words for example ruby-on-rails using PHP.
...
Every ajax chat tutorial ends the same.
You run a getChatMsg.php or some script every X milliseconds to check for new messages.
But not omegle.com they only send you a packet when you really need it not every X milliseconds.
For example I run every ajax chat tutorial i setup and sniff the packets I get a flow of getChatMsg or similar ...
hi there friends,
i was wondering if there is an API for a shopping cart (PHP). I have looked at solutions like opencart etc, but i have my own design and i just need some kind of API which i can use and add the shopping functionality directly into my website.
I was thinking like
ExternalCart->createNewProduct(...); or
ExternalCart->s...
I am creating a report in Table format.
This report is displayed on the browser.
I want to provide a download report in excel format link so that the report can be available in excel file also.
How can I do this
...
Title says it all. I already "did" this for IPv4;
$ip = '127.0.0.1'; // example
$ip = explode('.',$ip);
if( count($ip) != 4 ) $ip = array(0,0,0,0); // wrong ip format, default to 0.0.0.0
return chr($ip[0]) . chr($ip[1]) . chr($ip[2]) . chr($ip[3]);
I need to do the above for IPv6 as well. Reading through the IPv6 spec, (I admit I didn...
please tell me how can i remove "Powered Free by PHPmotion - Video Script" from phpmotion v3.5
...
I would like to split a text
过公元年?因为无论你如何选择。简体字危及了对古代文学的研究输入!
Using on of these three (or more) ?!。 characters as delimiter.
i can do this of course with
$lines = preg_split('/[。,!,?]/u',$body);
However i wan't to have the resulting lines keep their ending delimiter. Also a sentence might end like so 啊。。。 or 什么!??!!!!
...
I'm struggling to find out which PHP-Frameworks does the best job when it comes to integrate with jQuery as Frontend-Framework. Zend seems to work best with Dojo, CakePHP with Prototype, but my favorite one JQuery seems nowhere to be supported out of the box.
For example CakePHP has a pagination helper, but it works only with Prototype ...