-
Calculate Time Difference
Date: 11/11/05
(PHP Community) Keywords: php, mysql, sql
I am using this code to calculate hours:
$hoursITEM = (strtotime($end_time) - strtotime($start_time))/3600;
We want to use "24:00" midnight (military time)at the end of a shift. Unfortunately this results in an error.
Whats the best way to handle this?
***
Whatever I decide to do it's going to effect this MySQL query
$Query = "SELECT invoice_number, sum(((TIME_TO_SEC(end_time) - TIME_TO_SEC(start_time))/3600) * rate) AS subtotal FROM invoice_items WHERE office_id='$office_id' AND service_type!='225' GROUP BY invoice_number ORDER BY invoice_number";
Thanks for your help...
[More thoughts]
I guess we could use 00:00 and then absolute value to get rid of the negative... As long as I can do that with the Query too.
Shoot - 00:00 is interpreted as 0... 00:00 - 06:00 = -6. For the PHP I can juggle it to work. "if "24:00" yada yada
[After doing some test with MySQL]
I guess I dont have to worry about MySQL, its computing:
sum( ( TIME_TO_SEC(24:00) - TIME_TO_SEC(06:00) )/3600 )
as 18 hours.
I guess I can accomodate for the PHP because that part is for display on one page.
After we can wipe out a series of bugs we are going to go back and add an end date. We just need to get this functional for the time being.
Source: http://www.livejournal.com/community/php/366221.html
-
Tripod websites
Date: 11/12/05
(PHP Community) Keywords: php, mysql, database, sql, web
Hello All. Just a short introduction.
I'm Sam, 17 years of age from England. I'm currently a student, and am soon to leave for university to study computer gsmes development, which should be fun.I've been teaching myself php along with MySQL for about a week now, and all has been pretty good so far. It's surprising how simple php really is.
Now thats over with, I have a small problem. I'm not sure if this is the right place to ask, but here goes:
Does anybody have any experience making websites hosted by the free lycos tripod service? If so, how do you get php to communicate with MySQL in it? I've created a site that works fine on the test server I've created, but as soon as I upload it to tripod, it just stops working. The lycos help page said it would automatically connect to and select your database at the beginning of the script, so I figured you just skip all the mysql_connect() stuff and start straight away with the queries, however it still doesnt work. I know for a fact my query is fine, as I copied and pasted it straight into the mysql client and it all worked beautifully.
If all else fails, could you recommend a good, preferably free php and MySQL webhost?
Thankyou Greatly
Sam
Source: http://www.livejournal.com/community/php/366601.html
-
Authenticating on a Windows domain with IIS
Date: 11/14/05
(PHP Community) Keywords: php
Hey guys,
I'm currently working on a corporate intranet, and I'd like to avoid having users enter two passwords in the morning when they log in. Is there any way to have the intranet authenticate the user based on their windows domain username?
For the record, I'm using php5, and IIS6. The user machines here are a combination of windows flavours, ranging from WinME (only used for a print server -- I can ditch this for intranet access), Windows 2000 (most users), and Windows XP (myself).
I've come across this script:
/*
Getting netbios info
CopyLeft 2002 (GNU GPL V2) by polo
*/
error_reporting(E_ALL);
/* get the ip of the client */
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
echo 'ip : '.$ip.'
';
/* send a "special" packet */
$fp = fsockopen('udp://'.$ip, 137);
fwrite($fp, "\x80b\0\0\0\1\0\0\0\0\0\0 CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\0\0!\0\1");
/* wait 2 secs, and get the data */
socket_set_timeout($fp, 2);
$data = fread($fp, 256);
/* get netbios records number */
$nbrec = ord($data[56]);
/* display nebios records : the username is a record of type 3 */
echo '';
echo 'no | type | valueh> |
';
for($i = 0; $i < $nbrec; $i++) {
$offset = 18 * $i;
printf ("%02d | %02X | %sd> |
", $i, ord($data[72 + $offset]), trim(substr($data, 57 + $offset, 15)));
}
echo '
';
?>
It works, but I'm stuck on how to use that in site (how do I identify that 03 entry which shows the windows username).
ip : 192.168.49.15
no | type | value |
---|
00 | 00 | COMPUTER_NAME |
01 | 00 | SYDNEY |
02 | 03 | NET_NAME_1 |
03 | 20 | COMPUTER_NAME |
04 | 1E | SYDNEY |
05 | 03 | MYLOGIN |
Any suggestions would be appreciated.
Source: http://www.livejournal.com/community/php/367349.html
-
Request For Comments: PHP ANN goodness!!!
Date: 11/13/05
(PHP Community) Keywords: cms, php, programming, web
Hi, I am a final year degree student, reading artificial intelligence. One reference script I have written is PHP Input Filter which is now being deployed in a number of websites, including a couple of CMS.
My dissertation project has two main aims, the first is to create a flexible PHP set of classes for [data classification] ANNs. On top of this and supporting it will be a web 2.0 influenced web app to construct, test and deploy ANNs for your web development projects.
I am looking for XP-style customers to help me create and choose priorities during this academic year. This should take up a very small amount of time on a fortnightly basis. Please comment if this project interests you!
Customers do not have to know anything about the working of ANNs, you just need to know a little about their uses and that you would like to implement them but not how. My project has two focuses; the first is to develop a neural network php class and supporting classes that can create, load and save NNs and be used within other projects. The second part of the project is a supporting webb app to guide you through the entire process (although advanced ANN developers could skip this and just use the classes). The web app would initially teach you about the uses of ANNs, A non-bloated interface would allow you to construct them and test them, and finally you could either download the sourcecode and accoumpnying datafile to store on your server/db or use your account with the web app to store them on the project website and interface through web services (SOAP).
In eXtreme Programming, customers create the requirements with a simple system, they think up as many individual "things" the project should achieve and write each down as an extended sentence. These are gathered together and the most critical chosen by the customers themselves. These priorities are taken into the first interation of the project cycle. At the beginning of each 1-2 week project iteration, new priorities are chosen by the customers for the next cycle.
Source: http://www.livejournal.com/community/php/367024.html
-
mysql rows
Date: 11/16/05
(MySQL Communtiy) Keywords: php, mysql, sql
Hi, I feel a bit silly asking this. I don't think I quite understand how to apply functions such as mysql_num_rows() or MySQL commands such as COUNT().
Obviously I'm having trouble with some code, but I want more general answers before working on the code.
Can anyone explain how to count the number of rows from a table which have a particular value in a particular column? What if one or both of those are variables?
Thanks in advance. :)
Cross-posted to php.
Source: http://www.livejournal.com/community/mysql/72773.html
-
Another MySQL query question
Date: 11/16/05
(PHP Community) Keywords: php, mysql, sql
The query I have is this:
$query1 = "SELECT DAYOFMONTH(eventdate) as day, DAYOFMONTH(enddate) as endday, event FROM calendar WHERE MONTH(eventdate) = '$month' AND YEAR(eventdate) = '$year' AND type = 1 ORDER BY day";
$result1 = mysql_query($query1) or die('Query failed: please try again ' . mysql_error());
The accompanying result php code I have is this:
while ($a_row = mysql_fetch_array($result1)) {
if ($a_row['enddate'] != '') {
print "< font size=-2>".$a_row['day']." to ".$a_row['endday']." - ".$a_row['event']."< br>< /font>";
}
else {
print "< font size=-2>".$a_row['day']." - ".$a_row['event']."< br>< /font>";
}
}
I get no errors anywhere; it simply only prints the else part and doesn't examine the if part. Is this just the wrong way to go about it? Or am I missing something elementary?
Source: http://www.livejournal.com/community/php/367619.html
-
How To Display Blog Statistics Like This Blog?
Date: 11/17/05
(Java Web) Keywords: php, web
This blog displays statistics on the right-sidebar (bottom) like - There are currently #### posts and #### comments in this weblog. The data is obviously dynamic.
Andre recently asked me how I do it. Here is a simple solution.
Embed the following code in your sidebar (or elsewhere) in location of your choice:
<?php
$numposts = $wpdb->get_var("SELECT COUNT(*) [...]
Source: http://blog.taragana.com/index.php/archive/how-to-display-blog-statistics-like-this-blog/
-
How To Find Your PHP.INI
Date: 11/17/05
(Java Web) Keywords: php, web, apache
I often come across this question: Where is my php.ini located? Here is a simple solution.
To find out which php.ini your apache server is using please follow the steps below:
1. Type in the following in a file named say test.php and save it in document root of your webserver, normally htdocs for apache:
<?php phpinfo(); ?>
2. [...]
Source: http://blog.taragana.com/index.php/archive/how-to-find-your-phpini/
-
SimpleXML doesn’t Work with PHP 5.x: Problem & Solution
Date: 11/17/05
(Java Web) Keywords: php, xml
SimpleXML is PHP 5.x way to handle XML. It is simpler than DOMXML (which incidentally is very poorly documented in manual or elsewhere) which is available on PHP 4.x and much simpler than SAX solutions. However it doesn't work with certain installations of PHP 5.x. Let's see how we can solve it.
Problem
I first [...]
Source: http://blog.taragana.com/index.php/archive/simplexml-doesnt-work-with-php-5x-problem-solution/
-
Url location
Date: 11/17/05
(PHP Community) Keywords: php, mysql, database, sql
Hello everyone
This is my first post here so please go easy on me. I've been using/developing php for little over a year now, simple things (help desk, asset database) for my company. But there is 1 thing that has always bugged me and I can't find out how to do it.
I've noticed on some site's (blogs and php.net) that they dont have the usually page url, such as
http://www.somedomain.com/pages/about.php
but more like
http://www.somedomain.com/about/
or blog entries like
http://www.somedomain.com/blog/2005/11/09/
I just wondered how do they do that? I don't think they create a new directory for each entry or am I wrong there?
I know that is kinda of a vague question, it's just im redoing my blog atm (i use mysql for storing all my entries) and at the moment the url is usually like http://www.somedomain.com/blog/id=23232 < entry number
I'd really like to change that to http://www.somedomain.com/blog/2005/11/09.
If anyone can help that would be great
Source: http://www.livejournal.com/community/php/368298.html
-
Loading a MySQL Dump File via PHP NOT the mysql command line
Date: 11/18/05
(PHP Community) Keywords: php, mysql, sql
I've searched and searched and haven't found anything, so any help or direction would be greatly appreciated.
I have mysql dump files, that are very large, some close to 100 megs (ok large in my opinion), the contain the MySQL statements to dump the table if exists, create, then load the data. I had a daily routine where I would use the mysql command line to load them, but a server issue happened that caused the mysql command to not load due to a segment error (libs were upgraded that shouldn't have been - long story) however the mysql "service" works, and PHP connects to it just fine. What I would like to do is use a PHP script to load these dump files. I tried some script examples on php.net, but they failed, and I wanted to know if anyone else had done this successfuly? And how?
Thanks!
Source: http://www.livejournal.com/community/php/369639.html
-
SEEKING HELP WITH ONLINE PHOTOGALLERY. WILL EXCHANGE FOR FREE HOSTING!
Date: 11/19/05
(WebDesign) Keywords: php, html, java, web
hey guys,
I've been doing webdesign for a while, and have a pretty good knowledge of html. i am currently working on website for me and some friends of mine which will involve a photogallery with a lot of different subcatergories and seperate pages for each image, and it seems kind of pointless to go and create each seperate page for each picture, as well as keeping them under different catergories, photographers etc. i'd also like to have a very simple login and upload type thing so people can post pictures, define the catergory or subject, title, etc. maybe even something so that it automatically resizes the pictures to a set size. either way, this is beyond the realm of my web knowledge, and probably would involve php or something.
so, what i'm asking is, if anybody has a good knowledge of creating photo galleries with posting and sorting, etc (like a way paired down deviant art or something) i'd be willing to exchange some free web space and a subdomain (the website is polaroidbandits.com, so it'd be a totally hip domain to be hosted on haha) in exchange for helping me build this photogallery.
i'm pretty clueless when it comes to anything other than html and real basic javascript, so if you can help me out either leave me a comment or send me an email at tay@polaroidbandits.com
thanks!
Source: http://www.livejournal.com/community/webdesign/1019118.html
-
Two profiles; site works in one and not the other
Date: 11/19/05
(Computer Geeks) Keywords: php, browser
I use mozilla as my main browser. On it, I have two different profiles. One one I can get into the site below and enter text, while in the other profile the area to enter text blocks me out. Any idea as to why?
http://www.sports-boards.net/forums/newthread.php?do=newthread&f=34
Source: http://www.livejournal.com/community/computergeeks/818303.html
-
reading MS Word files
Date: 11/20/05
(PHP Community) Keywords: php, database
I built a template in PHP that allows the client to create / update lists of actors with their pictures and resumes. When creating or updating a resume, the client has to copy and paste the year, the name of the movie and additional information in 3 separate fields. The content is then added to the actor's personal table in the database.
Now the client thinks it's very boring to proceed this way, and would like to be able to just copy and paste the whole resume (or upload it as a word file).
Is it possible to do this using php ? I am no php god, I read articles about COM that suggested it was possible.
Any suggestion would be much appreciated !
Thx all
Source: http://www.livejournal.com/community/php/369708.html
-
POP3 Webmail PHP Script Reccomendations
Date: 11/23/05
(PHP Community) Keywords: php, web
Hello guys,
I was wondering if you could help me out here - soon I will be proving a service on my website for some friends so that they can have their own pop3 email addresses. But I want them to be able to access their email from a webmail PHP script - reason being I want it to use certain sessions with my website, and I can't be bothered to code my own webmail system :D
Does anyone know of a good, easy to install, customisable webmail system?
I've already tried a couple, and had no luck, I'm seriously looking for something quite simple, without all the frills (like address books, etc).
Cheers,
Xanni
Source: http://www.livejournal.com/community/php/370597.html
-
Any PHP Gurus wanna answer a question for me?
Date: 11/26/05
(Computer Geeks) Keywords: php, programming, mysql, browser, html, database, asp, sql
I've done plenty of ASP.NET programming but this is my first foray into the wonderful land of PHP and I've got a question about how often you hit the database in a normal page load... basically I have tags like:
within the front end page and listing.php goes something like
$database = mysql_connect("localhost", "your_database_user_id", "your_database_password");
mysql_select_db("your_database_name", $database);
switch($type){
case 'thumbnail':
header("Content-type: image/jpeg"); // act as a jpg file to browser
$query = "SELECT thumbnail
FROM your_table
WHERE id = $id";
$result = mysql_query($query, $database);
$row = mysql_fetch_array($result);
$jpg = $row["thumbnail"];
echo $jpg;
break;
case 'address':
header("Content-type: text/html"); // act as an html file to browser
$query = "SELECT address
FROM your_table
WHERE id = $id";
$result = mysql_query($query, $database);
$row = mysql_fetch_array($result);
$address = $row["address"];
echo $address;
break;
}
Now if I understand this correctly, anytime the parser hits a tag (or w/e) it will connect to and select from the database. So on a page with 5 tags that pull from listings.php, the scripts will connect to, select from and disconnect from the database 5 times right? Is this is proper way to do things? It kinda makes me uncomfortable to make so many database hits but this seems to be the average way php developers do it.
Source: http://www.livejournal.com/community/computergeeks/824527.html
-
Undesireable sticky form
Date: 11/25/05
(PHP Community) Keywords: php, mysql, sql
This is a first for me and I wonder if anyone else has ran into this problem. The code is really long and consists of several files so I'm not going to list it all. But I'll explain what it does and see if anyone has ever had this problem:
The "main" page runs a MySQL query. If they've never filled out the form, their data is not in MySQL, therefore the $_SESSION variable will not be set. The code that does this is near the top of the script (after including required files, etc.).
When the form is filled out and submitted, it calls the same page and also includes another file that processes the form.
Now with the information submitted and entered into MySQL, it runs back through the "main" page. The code that sets that $_SESSION variable runs a query looking for their entry and then sets the $_SESSION variable to true:
if ($characters) {
$_SESSION['characters'] = $characters;
$_SESSION['character_initialized'] = 1;
}
I've tested it with "echo debugs" and it is indeed within the if statement.
The only way the form is supposed to be shown is if $_SESSION['character_initialized'] is not set. The following calls the form:
if (!isset($_SESSION['character_initialized'])) {
include_once ($root_dir . 'content/create_character.php');
}
What happens is when the form is submitted, the form comes right back up! But any other click to a link then presents the page the way it's supposed to be. If you try to fill out the form again, it's just going to give back a message that you've already filled out the form.
So, am I missing something? I might want to add that the $_SESSION variables are within a function. Am I maybe having a variable scope issue? But then, if I am, I would think that the $_SESSION variable would NEVER get set and the second click on the page would just give me back the form again.
I have never had this problem before and have tried this script literally 30 different ways to find the problem.
Source: http://www.livejournal.com/community/php/370941.html
-
Problems with PHP image resize
Date: 11/27/05
(WebDesign) Keywords: php
I'm working on a script that scans a directory, and allows the user to select a file to use as a thumbnail for a gallery that will be created. It's scanning the directories fine, but when I try to create a thumbnail of each picture it gives me the text of the file, not the image. You can see a sample at http://www.internetporngod.com/chanta/galleries/admin/input.php?direct=japan3
I've tried a couple of different classes to do that and keep getting the same results. I know my variables are pointing at the right files, because I changed the code to each out an "img src" of the image and it showed the full size images...
Source: http://www.livejournal.com/community/webdesign/1022445.html
-
PHPBB vulnerabilities
Date: 11/27/05
(Web Development) Keywords: php
Is there a site that will scan a phpbb to detect any exploits? My friend's site just got hacked and we're trying to make it unhackable, now, obviously...
Source: http://www.livejournal.com/community/webdev/274655.html
-
Counting Charcters follow up
Date: 11/29/05
(Javascript Community) Keywords: php, xml, java
The reason for counting characters is to limit the number of characters... so when the count reaches 400, I put up an alert explaining the user has reached the limit.
However, because I am using onkeypress
to count the characters, it still "works" when the Javascript error is up. That then results in the is error in FireFox:
Error: uncaught exception: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMTreeWalker.nextNode]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://global/content/bindings/button.xml :: fireAccessKeyButton :: line 93" data: no]
My first thought was to trim the message. Didn't work.
My second thought was to kick the cursor out of the text box with blur.
if(size > 400)
{
gID("MESSAGE").value = gID("MESSAGE").value.substring(0,399);
gID("MESSAGE").blur();
alert("During Beta Testing Messages are limited to 400 characters. Your message is "+size+" characters long.");
}
But that doesnt seem to work. Any ideas?
BTW: the PHP does also trims the content - so the issue is just the UI and Javascript error, not the function.
Solution: Apparently there is a bug in FireFox 1.0.7 Mac that allows onkeypress to continue to work while the alert dialog is displayed. Disabling the text box before the alert, and then re-enabling it after the alert works. It also looks pretty slick. I'll probably do this anytime I have an alert regarding a form.
Source: http://www.livejournal.com/community/javascript/84773.html