-
Posts
476 -
Joined
-
Last visited
Everything posted by xProteuSx
-
Pikachu2000, Why is the code within the 'else if' statements not updating the original values? This is confusing for me, and will cause me further headaches if I don't understand. Thanks in advance.
-
Sorry Brett, but you're wrong. $days = $days + 1 only occurs if $days ever drops below a value of 0, which it does not. Also, this does not address the other values.
-
$days is originally = 1. $days +1 is only executed if if ($days < 0).
-
I have some code, such as this: $days = 1; $hours = -2; $minutes = -39; $seconds = 14; function fixTime($days,$hours,$minutes,$seconds) { if (($seconds < 0) || ($minutes < 0) || ($hours < 0) || ($days <0)) { echo 'running<br />'; if ($seconds < 0) { echo 'seconds: ' . $days . ',' . $hours . ',' . $minutes . ',' . $seconds . '<br />'; $seconds = $seconds + 60; $minutes = $minutes - 1; fixTime($days,$hours,$minutes,$seconds); } else if ($minutes < 0) { echo 'minutes: ' . $days . ',' . $hours . ',' . $minutes . ',' . $seconds . '<br />'; $minutes = $minutes + 60; $hours = $hours - 1; echo 'minutes: ' . $days . ',' . $hours . ',' . $minutes . ',' . $seconds . '<br />'; fixTime($days,$hours,$minutes,$seconds); } else if ($hours < 0) { echo 'hours: ' . $days . ',' . $hours . ',' . $minutes . ',' . $seconds . '<br />'; $hours = $hours + 24; $days = $days - 1; echo 'hours: ' . $days . ',' . $hours . ',' . $minutes . ',' . $seconds . '<br />'; fixTime($days,$hours,$minutes,$seconds); } else if ($days < 0) { echo 'days: ' . $days . ',' . $hours . ',' . $minutes . ',' . $seconds . '<br />'; $hours = $hours - 24; $days = $days + 1; fixTime($days,$hours,$minutes,$seconds); } else {} } } fixTime($days,$hours,$minutes,$seconds); echo '<br />' . $days . '<br />'; echo $hours . '<br />'; echo $minutes . '<br />'; echo $seconds . '<br /><br />'; The idea is for this to return: 0 21 21 14 0 = days 21 = hours 21 = minutes 14 = seconds At present it is returning: running minutes: 1,-2,-39,14 minutes: 1,-3,21,14 running hours: 1,-3,21,14 hours: 0,21,21,14 <---------------------- correct values! 1 <---------------------- incorrect values again! -2 -39 14 But as you can see, it reverts back to the original values! What the heck am I doing wrong? Thanks
-
Think I've got it figured out: $auctime = date_parse($endtime); $ebaytime = date_parse($curtime); if (($auctime["month"] <= $ebaytime["month"]) && ($auctime["day"] <= $ebaytime["day"]) && ($auctime["hour"] <= $ebaytime["hour"]) && ($auctime["minute"] <= $ebaytime["minute"]) && ($auctime["second"] <= $ebaytime["second"])) {//auction is over} ... seems to be getting it done.
-
Man, this timestamp is ridiculous (I am a noob). Here is what I have tried to do: $endtime = 2012-12-13T12:36:59.000Z; $curtime = 2012-12-13T12:12:44.723Z; Find the difference (the difference should be around 25min); Here is what I have tried: $endtime = strtotime($endtime); $curtime = strtotime($curtime); echo date_sub($auc_endtime,$ebaytime); The issue is that I get the following error: Warning: date_sub() expects parameter 1 to be DateTime, integer given Should I be using date_parse? The issue for me is that I have to use something lightweight. I am comparing two timestamps; one is from eBay so I have to make an API call which delays my page loading time, the other is a timestamp from a database. The whole point is to speed up the process of calculating days, hours, minutes, and seconds between these timestamps.
-
Awesome, thanks for the pointer. I was trying to follow this: http://forums.phpfreaks.com/topic/96654-ebay-time/page__hl__+ebay%20+timestamp#entry494620
-
I am having trouble finding the time between two timestamps. I have tried to research this, but I don't even understand this timestamp format. This is the format for the data I am given (I have no choice in this!): 2012-12-13T11:34:16.771Z I don't even know what the T and Z stand for! .. and I can't seem to figure it out. I have a second date to compare to this. For example: 2012-12-13T12:04:29.000Z I have to figure out the difference in days, hours, minutes, and seconds. There must be a php function that can return the difference, if only in seconds (I can handle it from there). Any ideas? Thanks in advance!
-
I am mid install on ZenCart for one of my clients, but I have to admit that this is my first time installing an eCommerce shopping system. That having been said, I am having serious doubts about my choice. ZenCart appears to be very common, but I thought I would call on a much more experienced community (YOU!!!! yay!) for some guidance: - I need a scripted site where I can add products, prices, descriptions, etc - The site template needs to be easily customizable - I need to be able to integrate PayPal payments (credit cards) - Users are able to purchase products using a credit card WITHOUT registering any accounts Is ZenCart the right choice? If there is something much better, at a reasonable price, I am willing to pay ... TIA!
-
Find all single and multi-digit numbers in a string
xProteuSx replied to xProteuSx's topic in Regex Help
Wow, that is beautiful. Thanks a lot. One day I will learn this regex stuff! -
I am not good with regex, and I can't seem to find a solution to my problem either on these awesome forums, or on Google. I have strings, such as the following: $string1 = 'P20DT13H8M46S'; $string2 = 'P8DT8H14M3S'; The first number is a day (D), then there's a hour (H), minute (M), and second (S) So, $string1 is roughly translated to P 20 Days T 13 Hours 8 Minutes 46 Seconds. What I would like is to write a regex expression that extracts the numbers from each string, whether they are single or double digit to produce an array like this: echo awesomeFunction($string1); // results in 20, 13, 8, 46 echo awesomeFunction($string2); // results in 8, 8, 14, 3 Any idea on how to do this?
-
Well, I do appreciate you telling me that it won't work, but as you can see I've figured that much out. There must be a way to do this, and to be able to use an image that is more than 1px wide. The image I am using must be 330px wide, and at least 300px high. It seems as though others have been able to do it, but I can't figure out, for the life of me, what I am doing different than them. I have tried their tutorials and advice, but I am obviously doing something different.
-
I just cannot, for the life of me, get this to work! I am trying to make a div height=100% and fill it with a background image. The page in question is as follows: http://www.neovidamedia.com/work/salveo/about_salveo.html The style sheet is here: http://www.neovidamedia.com/work/salveo/salveo.css If you take a look, after the header there is a div called 'content'. Within the 'content' div there are 'content_left' and a 'content_right' divs. 'content_right' is the one that I am trying to stretch to 100% height, and to fill it with this semi-transparent graphic: http://www.neovidamedia.com/work/salveo/images/call_salveo.png Within the 'content_right' div is another div entitled 'content_right_top' which contains some text etc. This idea is to have this call_salveo.png graphic fill any blank space below the 'content_right_top' div for the full height of the page minus the header and footer divs. I can't get this to work except by adding <br /> tags under the 'content_right_top' div, which is nonsense. Thanks.
-
Ofcourse ... 12 seconds later it works: SELECT * FROM my_table WHERE user_date_visit < DATE_SUB( NOW( ) , INTERVAL 60 DAY )
-
I am trying to do something like this: SELECT * FROM mytable WHERE user_date_visit > DATE_SUB(user_date_visit, INTERVAL -60 DAY) Essentially I have a members table and I have their last login in the following format: YYYY-MM-DD I would like to select all data for all members who have not logged in in the last 60 days. I keep on playing with the MySQL query, but I just can't get it to work. It always either selects all the members or none of them. Some help would be appreciated ... Cheers.
-
Is there a way to do this using mysql? SELECT * WHERE year < 2000 AND year > 1900 for example?
-
I've got a site that passes a few variables from one page to another using an HTML form and the POST method. These variables are then used to perform an action. Now I am coming up against an issue where if the browser gets refreshed, the action is performed more than once. What is the general protocol to avoid this issue? Or is there a standard protocol?
-
jcanker, Thanks for the reply, but I have no idea what you are talking about. Nowhere in that code do I refer to particular index. I am familiar with the use of square brackets, but where in my code does that apply?
-
I have done this before, but it seems that I am doing something wrong this time. I have a function such as this: $numsarray=array(); function checkChores($a) { $match = 0; if (count($numsarray) > 0) { foreach ($numsarray as $chorenum) { if ($chorenum == $a) {$match = 1;} } } if ($match == 0) {array_push($numsarray, $a);} } So if I do the following: checkChores(3); checkChores(4); checkChores(3); When I do this: print_r($numsarray); I should get: Array ( [0] => 3 [1] => 4 ) Instead, I get the following error: Warning: array_push() [function.array-push]: First argument should be an array in /home/pgagnon/public_html/errorlog.php on line 19 This is line 19: {array_push($numsarray, $a);} How is $numsarray not an array??? Help!!!
-
The redirect to self, using header("Location: index.html"); exit; did not work. However, I just made the form action="login.php" which processed the input, then redirected back to index.html. That worked. Thanks for the heads up. I wonder why you can't use cookies right away, like session variables?!
-
So, Thorpe, is that to say that you can't use the cookies on the page they were created on unless you refresh or leave the page and come back? If so, is there a way around this?
-
making upload form, file not uploading. HELP!!
xProteuSx replied to m1k3yb0y's topic in PHP Coding Help
... I haven't gone over your code, but I know that a frequent problem is that people forget to CHMOD the directory to which they are uploading. Just check that out. I believe it should be 755. -
I am working on a login script and I am using cookies for the first time. I have it something like this: <?php if (correct user/pass entered) - set user/pass cookies ?> <html> <?php if (user/pass cookies are set) {echo 'you are logged in';} else {echo 'you are NOT logged in';} ?> </html> The problem is that if I enter a valid username and password, and the cookies are set, then I get the message 'you are NOT logged in' unless I leave the page then return to it, or if I refresh, in which case I get the message 'you are logged in'. Its almost as though I cannot use the cookies until I navigate away from the page on which they were set. Am I doing something wrong, or is this the way it works?
-
I've got it figured out, I think: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> Can anyone send me a link or enter some info about doctypes? Just some general notes. I have Googled it, obviously, but don't really understand the exact importance of this, and can't figure out why you need different doctypes, instead of having a default and all-encompassing one. Cheers.
-
jesirose, I am not very familiar with doctypes at all. I just kinda use the default doctype that dreamweaver spits out. What doctype should I be using? Thanks for your reply! PS - PHP Goddess? (lol??)