Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. No worries. In essence here is your problem: As you've seen, you can color the background of the TD. Which you do in this block of code: if ($month == $currentm && $dayArray["mday"] == $currentd && $firstDayArray['year'] == $currenty) { echo "".$dayArray["mday"]." ".$event_title."\n"; } else { echo "".$dayArray["mday"]." ".$event_title."\n"; } One problem is that you are replicating two lines of code to do the exact same thing, when the only thing you really are interested is setting the "bgcolor=" attribute in the td. The second problem is that you never determine whether or not there is an event. Based on the way you have written your code, you could do this using empty() on the $event_title variable. If there's an event empty() will be false. What I'd suggest is that you initially determine what your bgcolor needs to be (default, today, or event). Of course you have the issue that if there's an event today, you haven't indicated what you want to do. I'm just going to give you code that sticks with it being yellow. Just prior to your if else statement above, insert code something along these lines: $bgc = ''; // default no bgcolor if ($dayArray['mday'] == $currentd) { $bgc = ' bgcolor="yellow"'; } elseif (!empty($event_title)) { // Set event color $bgc = ' bgcolor="green"'; } if ($month == $currentm && $firstDayArray['year'] == $currenty) { echo '".$dayArray["mday"]." ".$event_title."\n"; } Notice that you no longer need the if - else of the original block, so this should replace what you had previously.
  2. You are correct when you state that you haven't been clear. Additionally, when someone replied to you with a suggestion, your answer was: doesn't work, nobody wants to waste their time. Your question at this point seems to have nothing to do with PHP, but rather is an html/style question. Are you able to create a pure html mockup which employs whatever coloring you are trying to accomplish? If so, then you should be able to automate the coloring. I don't see any reason why you would be trying to complicate this with javascript, but then, your original post didn't do a very good job of explaining what it is that you wanted in the first place.
  3. Also, for what it's worth, using Global variables is not the best idea in my opinion.
  4. I have to disagree with Lodius2000, the line of code is correct. It will only add to errors if the size has no acceptable value. Using OR will guarantee that it always errors out. The reason you get the warning, is that the code attampts to use the value of $_POST['_submit_check'] when it doesn't exist. You could mitigate this in a couple of ways, one being adding the @$_POST['_submit_check'], or adding an isset($_POST['_submit_check']) && I'm not really sure why the form doesn't work -- I didn't see anything obviously wrong with the code. What is the exact validation error you get, and what was the input?
  5. Yeah you posted that just before I hit enter I guess. Without scrutinizing too much of your code, in the case of name search, this is clearly not going to work, because you apparently have a first name and last name, however, you are not attempting to break the name into its constituent parts. In that case you need to do something -- explode it on the space would be one way to handle it.
  6. I don't see a problem with the regex. The question is, what do you do after you get into your loop? How are you attempting to search the database? What database are you using, and what is the SQL syntax you're using?
  7. Congrats on your milestone. Just remember that what is important is the quality of the posts, not the quantity
  8. No he didn't say anything about sticking things in the database. All he pointed out was that the function provided could be converted so that it no longer used font tags. The proper way to do this is to use around the names. In your style sheet you simply need to define class styles that match the font statements you use, then emit the span with the appropriate .css class. So in your .css file, you would define classes for each of your name styles. For the color that would be as simple as something like this: .staff { color: gold} Now in your function you emit the span with the class tag around the name, in the same general way you are using FONT. Voila, you have started on the important path to xhtml compliance. else if($member['staff'] >= 1) { echo '' . $member['username'] . ''; }
  9. Your Fields are terminated by a ',' . Hopefully there are no embedded commas in the addresses anywhere as that will completely screw up your import.
  10. Hello sir and Madem would you read my book, took me years to write, would you take a look? It's based on a novel by a man named Lear and I need a job cause I wanna be a Paperback writer --- Paperback WRITER! Paperback writer writer writer. It's a dirty story of a dirty man and his clinging wife doesn't understand. His son is working for the Daily Mail, It's a steady job but he wants to be a paperback writer, Paperback WRITER! It's a thousand pages, give or take a few, I'll be writing more in a week or two. I can make it longer if you like the style, I can change it round and I want to be a paperback writer, Paperback WRITER. I wrote some SQL, Some MySQL too, what the difference is I can't say to you. So I posted here, but I'm ESL, so you're scratching heads wondering what the hell's this Paperback writer, Paperback WRITER!
  11. Did you read my answer? I already provided a solution. Mchl has a good point in regards to unique indexes, however, there is a limit to the size of an index that you can create on text, and I personally would probably go a different way. I think a fair compromise is to use the IP address, which will only really become a problem if you have people who leave lots and lots of comments, using the same IP. I think this could be mitigated if you added a timestamp column to the table which was indexed. IP Address should also be indexed. Neither of these indexes will be unique, but together they will help restrict your result set to a manageable size. Then you could do a query which only attempted to check for comments that are the same for that IP and the previous 5 minutes, which would insure that you maintain good performance as time goes on and your database fills with comments. This blog post covers mysql date arithmetic: http://www.gizmola.com/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html
  12. I did answer you, if you read what I said. What is it that you didn't understand about the fact that you can only have one color be transparent?
  13. For #1, the recommended way of avoiding SQL injection is to use prepared statements and bind variables. The second best solution is mysql_real_escape_string. One thing to watch out for is that mysql_real_escape_string is like a hammer -- it will *fix* binary data just as easily as it will fix text, and in some cases that could cause problems. So if you need to, for example, compare md5() hashed data with stored md5 passwords, or to store binary data (pictures perhaps) then you should not run mysql_real_escape_string on that data before you hash it. The hash process itself is immune to any issues, since it transforms the input. For #2, we don't really have enough info. If you're searching the comments table for a match, then the best solution is to do SELECT count(*) as countof FROM table WHERE IPAdress = "$ip" AND comment = "$thecomment$". You will always get a result, and the result will only be an integer. On anything > 0, you don't do the insert.
  14. Any place you take data that comes from a foreign source, sql injection is a possibiity.
  15. I just want you to know that every place you have LIKE %something% your database will not be able to use an index. MySQL does have a solution for this -- the fulltext index. You might want to do some reading on it. Otherwise, as time goes on, your searches will begin to crush your mysql server, and eventually (assuming your database starts to fill up with pitches) performance will become worse and worse.
  16. That is because transparency is created by defining only one color value as transparent. Partial transparency is available in PNG, using Alpha channels, however an image with an alpha channel is a completely different beast. Alpha channels involve the combination of a per pixel Alpha blending value. So the first thing you need to know is that alpha channels in the png spec only work with png images that use 8 or 16 bit color. Rather than specify a color that should be rendered transparent, an alpha channel acts as a mask value on a per pixel basis, indicating what opacity the pixel should have. This is simplifying the question a bit, because png's using an index table, can also specify an alpha value for a particular color in the color table index, which is probably the closest thing to what you originally inquired about. There's an example of merging images to create a watermark effect in the php manual that touches upon some of this material: http://us.php.net/manual/en/image.examples.merged-watermark.php
  17. BTW, you might ask why not use the SHA or MD5 versions above. If you want to take that approach I have no complaint with doing so but it does have these drawbacks. -Those hash functions are computationally expensive. -The hashes themselves are very long (36 or 40 characters depending on which you choose). If you want something shorter, you might want to consider the approach I outlined. The function can actually create whatever size string you want, but you could start producing collisions if it was too short. 6-8 characters provides a nice compromise.
  18. I wrote one of these recently, and there was very little involved. My code did check in the database to make sure that the string hadn't been allocated previously, but that is something you will have to code for yourself. This simple function does the work of generating a random string. I also didn't want the first character to be a zero, so I have a little code to prevent that, but you could obviously omit that if you wanted. As you can see, it's pretty simple stuff and just does a few ascii lookups in combination with rand(). This is nothing you couldn't write yourself or modify to your liking. For my purposes i wanted a string that had numbers and letters. public function generateInviteCode($charnum = { $invitecode = null; $startrange = 1; for ($x = 0; $x $rand = rand(0, 61); if ($rand $invitecode .= $rand; else if ($rand $invitecode .= chr($rand + 55); } else { $invitecode .= chr($rand + 61); } } // on first character, don't allow a zero if ($invitecode[0] == '0') $invitecode[0] = rand(1, 9); return $invitecode; }
  19. In an html select element, there is a difference between what is displayed and what is the value for an element in the select list. It's basic HTML markup.
  20. As you've seen there is no problem instantiating an object of class A inside of class B. You simply do this type of work inside a method. You can't declare a class variable and instantiate an object in the declaration, but that's simply syntax.
  21. Best practices to help avoid these issues is to always exclude the closing ?> tag in your scripts.
  22. When you utilize a timestamp column in mysql there is no need to specify any type of default. It willl already default to server time. The only issue with using timestamp is that if the table is updated the timestamp will also be updated, so this defeats a 'createdDate' type function if the rows might be updated at some later time.
  23. Yes -- as I stated in my reply, Putty. Putty is a free open source ssh implementation for windows.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.