Jump to content

End User

Members
  • Content Count

    309
  • Joined

  • Last visited

Posts posted by End User

  1. A common question : I have a shopping cart, And i have :X - products,Y - The amount of money per product,Z - How many products i wish to buy.I wish to calculate the Product cost (Y) multiply (*) by the amount of products (Z). aka Y * Z.
    This sounds like a homework problem to me.
  2. I have the fields set as integers, any help really appreciated.
    I could be mistaken, but if they're integers then there won't be any values between whole numbers. An integer column won't store a value like '35.00000', it'll truncate it and store '35'. You can store a negative number, i.e. '-50', but not '-50.003'.
  3. I think this looks much, much better. Much easier on the eyes, and the red now acts as a nice accent to offset parts of the page.

    I've done up a photoshop mockup of the front page with different colors.I'll just link to it, since it's a big picture:http://www.rpgmmag.com/imagine/imagez/colo...17_71144883.pngIn it, I left the header, footer and navbar section the original color scheme and the content of the page to a darker, gray color. White is still a lighter color than gray, but I'm hoping that the contrast and headaches should be reduced.
  4. When you say that the colors are daunting or too strong, in what way do you mean? Like the colors are too bright?
    White text on a red background is difficult for the eye to process easily, but it (paradoxically) is also one of the more attention-getting color combinations that appear to be hard-wired into the human brain. (Think stop signs and other warning signage. The other hard-wired "alert/danger" color combo is yellow on black.)It's why you never, and I mean *never* see a book printed in white-on-red. Or red-on-black. The eye likes high contrast but also little or no color when processing text. It also likes the lighter color, whatever it is, to be the background color. For example, it's much, much easier to read a paragraph of red-on-white text than white-on-red text. It's less "tiring" on the eye/brain. For short amounts it's not a big deal, but for a whole site it's overpowering and tiring on the eyes (as well as psychologically tiring to some degree). Headers and banners in white-on-red are one thing, but to have the majority of the site in that combination is going to be overpowering to a lot of people.
  5. Textarea tags need to be closed, and no "type" is needed. They also don't take a "value" param:<textarea name="order" rows = "5" cols = "50"/>$row['order']</textarea>

    I need to allow a user to edit text on a website, so I fill the form input areas with the fields from the appropriate table. But, when using <input type="textarea", etc. etc., the form simply shows as <input type="text"> Is there a special label that I should be using so that the input area that is populated with data from a database field shows up as an html textarea?
    echo '</label><input type="textarea" name="order" value = "' . $row['order'] . '" rows = "5" cols = "50"/><br />';

  6. Hmm. Flash isn't great for SEO, and there are numerous rumors of canvas replacing it.
    He wasn't asking about SEO, just what language or technology he should learn next. I think it may be a while (a year or so) before we see significant movement in canvas app development. It's still fairly new and not all browsers are caught up to it yet. I think in time it'll give Flash a good run for its money since it's much more accessible to developers than Flash.
  7. Flash has applications beyond just as a tool for creating web pages, though - you can create games and other fully client-side applications (e.g. with Air).
    If I was going to learn Flash, that would be my intent. Not to make a web site, but to create applications. I've seen some pretty impressive Flash apps, basically the equivalent of good desktop apps on the web, accessible through a browser.
  8. How about Flash/Actionscript?

    Does anyone have any recommendations on new things to learn regarding programming / web development? Any videos, books, or other tutorials I should dive into? I feel like I've mastered html/css. I've done plenty of javascript, ajax, and jquery, and i think i am pretty well versed in php, oop, using an mvc framework (i chose codeigniter), mysql, and using a variety of web services. My latest site (followthenookie.com) utilizes all of the above, so im not really sure what i should start learning next. any suggestions?
  9. do you mean by putting file outside of public_html?if yes..then how can i add image file putting it outside of public_html? i thought its not possible to do like this.
    Use a small intermediary script to fetch the image. Something like this (you'll need to modify it a bit). Untested, may have bugs, may cause blindness.
    // show_image.php// the image name $img = 'some_image.png';// create full absolute path to actual file object $fn = "/server/path/to/the/$img";// get extension$path_info = pathinfo($fn);$ext = $path_info['extension'];// show only approved filetypesif($ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png'){	// set header 	if($ext == "gif"){header('Content-type: image/gif');}	if($ext == 'jpg'){header('Content-type: image/jpeg');}	if($ext == 'jpeg'){header('Content-type: image/jpeg');}	if($ext == 'png'){header('Content-type: image/png');}		// stream image out to browser	header('Content-transfer-encoding: binary');	header('Content-length: '.filesize($fn));	readfile($fn);}

    Use this by calling it from an IMG tage:<img src="show_image.php'>

  10. I'd suggest doing some of the classic beginner projects, like a guestbook or contact form, then move on to more complex projects like an image gallery or simple message board. For me the best way to learn was to grab a script and start modifying it. I found it helped a lot to start with something that already works and make changes.

  11. If you're making HTML edits it could be browser caching, but I'd bet that it's not actually saving the changes, perhaps due to a permissions issue. If you FTP the file down and look at it, are the changes actually present in the file? I'm not familiar with VS, so I may be way off base.

  12. Some coders use anonymous functions when they only require the function to be run from one particular location (instead of making a full, separate function out of it). There's some debate among programmers as to whether or not anonymous functions are a "proper" coding style, since they can make code a bit harder to puzzle out.

  13. Yes - the way you access it depends on what language you are using. With PHP, for example, you can use the $_SERVER['REMOTE_ADDR'] index.
    This will return some valid IPs, but if they're using a proxy or other forwarding mechanism you may want to go with something like this:
    // try and get the real IP address...if (getenv('HTTP_CLIENT_IP')) {	$ip_address = getenv('HTTP_CLIENT_IP');}elseif (getenv('HTTP_X_FORWARDED_FOR')) {	$ip_address = getenv('HTTP_X_FORWARDED_FOR');}elseif (getenv('HTTP_X_FORWARDED')) {	$ip_address = getenv('HTTP_X_FORWARDED');}elseif (getenv('HTTP_FORWARDED_FOR')) {	$ip_address = getenv('HTTP_FORWARDED_FOR');}elseif (getenv('HTTP_FORWARDED')) {	$ip_address = getenv('HTTP_FORWARDED');}else {	$ip_address = $_SERVER['REMOTE_ADDR'];}

  14. I tried your SQL but it kept returning an empty set. It may have been something I was doing wrong, but I don't know. If you're bored and want to play with it, here's my test table:

    CREATE TABLE IF NOT EXISTS `test_table` (  `event_id` int(11) NOT NULL auto_increment,  `start_ts` datetime NOT NULL,  `stop_ts` datetime NOT NULL,  PRIMARY KEY  (`event_id`)) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9;-- Dumping data for table `test_table`INSERT INTO `test_table` VALUES(1, '2010-10-03 13:22:28', '2010-10-05 13:22:33');INSERT INTO `test_table` VALUES(2, '2010-10-12 13:45:19', '2011-01-30 13:45:39');INSERT INTO `test_table` VALUES(3, '2010-10-26 12:51:14', '2010-11-02 12:51:20');INSERT INTO `test_table` VALUES(4, '2010-11-03 12:49:17', '2010-11-05 12:49:20');INSERT INTO `test_table` VALUES(5, '2010-11-10 12:48:26', '2010-11-13 12:48:30');INSERT INTO `test_table` VALUES(6, '2010-11-21 12:49:24', '2010-11-24 12:49:31');INSERT INTO `test_table` VALUES(7, '2010-11-29 12:49:58', '2010-12-08 12:50:03');INSERT INTO `test_table` VALUES(8, '2010-12-20 13:23:01', '2010-12-27 13:23:09');

    When I run my hacked up load o' code for events that touch November, here's what I get:Event: 2|1286909119|1296416739Event: 3|1288115474|1288720280Event: 4|1288806557|1288979360Event: 5|1289414906|1289674110Event: 6|1290365364|1290624571Event: 7|1291056598|1291834203(I realize some of these events do overlap, but this was just for testing purposes.)

  15. I haven't tried that yet, but I think I was "over thinking" this and making it harder than it was. In PHP I think it's very simple. I'm still going to try your SQL and see if it works because it would probably be a faster way to get the data, but here's what I came up with in PHP...I cut out a lot of code here that deals with converting to timestamps and whatnot, but this POC code *seems* to work. It's within a loop that pulls all of the client's rows from the DB:

    	// is the START date AFTER the end of target month?	if($event_start_stamp > $end_of_month){		print "<b>Discarding:</b> $event_id, Start: $start_ts to $stop_ts <br>";		continue;	}	// is the END date BEFORE the start of target month?	if($event_stop_stamp < $start_of_month){		print "<b>Discarding:</b> $event_id, Start: $start_ts to $stop_ts <br>";		continue;	}		// if neither of the above conditions match, the the event touches our month..		print "<b>Keeping event:</b> $event_id, Start: $start_ts to $stop_ts <br>";		$proc_list[] = "$event_id|$event_start_stamp|$event_stop_stamp";

    Basically if the event end date is before the target month starts or the event start date is after the target month ends, it get thrown out. All the other rows touch the month in some way. This also captures events that span the target month...I think. At least it works on my test table.

  16. As far as I can figure, the basic logic behind the second code example I posted should work for that. It checks both timestamps to see if either of them fall within the specified month.
    Maybe I'm misunderstanding...Getting rows inside April are easy enough- I can look for any matches that have April (for example) as part of the start or the stop timestamp. But an event that runs from March to May won't match either of the timestamps. At the moment what I'm trying is something like this:1) Grab all the timestamps.2) Check if the end of the event is before the start of April *OR* if the start of the event is after the end of April. If either of these are true then it's not a matching event and the event is discarded.3) Check to see if the start of the event is before the start of April *AND* the end of the event is after April. If so, the event is kept (because it includes or spans April). 4) Grab and keep all the timestamps that have a start and/or stop time in April.I think this will give me a collection of all of the events that touch April. If I've got this right, I can then loop through all the collected events and (with a little extra calculating) figure out how much total time for the events in April. Please tell me if I'm having a brain cramp here and my logic doesn't seem right!
  17. I think this is close to what I need...almost. In addition to the rows in April, I'm trying to also get rows where the start date/time might be before April (like March 25th) and possibly end after April (like May 15th. In other words, find every row where the timestamps might not only be in April, but also include April (i.e March 25 to May 15). So I'm not sure this will do exactly what I'm looking to accomplish. (??)

    I hope I understand your question correctly. I've had to do something similar to this before in PHP. I ended up using the mktime function:This is what it looked like:
    $year = 2010;$month = 4;$db->query('SELECT * FROM tbl WHERE time >= '.mktime(0, 0, 0, $month, 1, $year).' AND time < '.mktime(0, 0, 0, $month+1, 1, $year));

    That piece of code would retrieve every row with a timestamp between the first second of April 1st and the last second of April 30th, in practical terms, from April to May.edit: In your case I guess it would look something like:

    $year = 2010;$month = 4;$start = mktime(0, 0, 0, $month, 1, $year);$end = mktime(0, 0, 0, $month+1, 1, $year);$db->query('SELECT * FROM tbl WHERE (time1 >= '.$start.' AND time1 < '.$end.') OR (time2 >= '.$start.' AND time2 < '.$end.')');

    BTW, mktime is a very smart function. If you ask for the 13th month of the year 2005, it will assume you meant January of 2006 and return the unix timestamp.

  18. I've been trying to get a good solution to a pair of problems and am looking for any ideas that might work. I have a list of timestamps that can span any number of days or months (including crossing a year boundary). The first problem: I want to get a list of all of the rows that "touch" or include a given month, like March. Like these, for example:2010-02-05 10:15:30 to 2010-02-15 08:25:30 (feb 2nd to feb 15th, doesn't touch march)2010-02-05 10:15:30 to 2010-03-02 08:25:30 (feb 5th to march 2nd, touches march)2010-03-05 14:20:30 to 2010-03-06 16:30:10 (march 5th to march 6th, touches march)2010-03-11 12:20:30 to 2010-03-14 18:22:10 (march 11th to march 14th, touches march)2010-03-27 15:20:30 to 2010-04-10 18:22:10 (march 27th to april 10th, touches march)2010-04-16 13:20:30 to 2010-04-18 09:22:10 (april 16th to april 18th, doesn't touch march)The timestamps (in theory) won't have any overlaps at all, they *should* all be sequential. That is, no two of them can overlap and include the same exact moment. They can butt right up against each other, but can't overlap or start/stop on the exact same minute (seconds will be ignored). So a time stamp can end on March 10th at 3:15pm and the next one could not start until March 10th at 3:16pm. They also can't "contain" an existing period. That is, if there was a period from March 5th to March 10th, there couldn't be a period from March 1st to March 20th.Question is, given the example set of timestamps above, how can I get all of the rows that touch or contain March?The second problem is an extension of the first one, sort of. Given the example above, if someone were to try and enter a time period that overlapped or contained any of the already existing time periods in March, how could I detect that? This is to make sure that they do end up sequential and don't overlap or contain any of the existing periods. Is there some SQL that would return all of the periods that touch March? Or, some SQL that would exclude all of the periods that touch March? I have a couple of ideas, but they're all pretty clumsy...I'm hoping someone here might have some suggestions as to how to accomplish these two things, or hopefully solve at least part of either problem.

  19. Two methods I've seen used:

    SELECT ROUND(RAND() * (SELECT MAX(id) FROM some_table));

    and:

    LOCK TABLES foo READ; SELECT FLOOR(RAND() * COUNT(*)) AS rand_row FROM foo; SELECT * FROM foo LIMIT $rand_row, 1; UNLOCK TABLES;

    If you have gaps or missing IDs, you may need to check and loop to make sure you get an existing ID. If you have lots and lots of missing IDs or gaps, this could be a problem..in that case I think all you can do is select a range of IDs and then randomly pick one of them. That is, select all IDs between 12345 and 53645, use PHP to shuffle() them and then pick one off the top of the array.

  20. I doubt that explicitly closing the connection is going to make much of a difference. You can try it but I doubt that will "fix" this problem.Most default configurations of mySQL set the maximum number of (simultaneous) connections to 100. To increase this you'll need to edit the 'my.cnf' file. On some platforms the file may have a different name, but that's usually it. In 'my.cnf', look for this line (mySQL 4.x and 5.x):

    max_connections = 100

    Change it to:

    max_connections = 200

    Restart mySQL after editing this value. You could use a higher number (i.e. 250), but that's rarely needed unless you have major, major traffic or some extremely convoluted SQL going on. However...before increasing the connection limit, you ought to try and find out why you're reaching the connection limit. Oftentimes a mySQL server that's hitting the connection limit has some kind of performance issue that could be corrected instead.EDIT: I should add that there is an additional situation where the increase is needed, even though your site doesn't see heavy traffic. If you host a number of domains on a single server, the traffic across all of the domains may exceed the shared connection limit, event though no single domain does. I have one server with ~100 active domains and although only a few see significant traffic if there's a spike in usage across a bunch of the domains, sometimes it will hit the connection limit (or it did until I increased the limit).

×
×
  • Create New...