Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. google watermarking tutorials. Same concept.
  2. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("slumtramp", $con); $email = mysql_real_escape_string($_POST['email']); mysql_query("DELETE FROM mailinglist WHERE email='$email'"); mysql_close($con); ?>
  3. well, you could do this: ~http://[^\.]*\.youtube\.com.*~ that would validate http://[anythinghere].youtube.com[anythingafter] If you have a list of specific subdomains you want to allow, you could do ~http://(a|b|c)\.youtube\.com.*~ where a b c is replaced by the specific subdomains (list all allowed ones in there, separating them with the pipe)
  4. Okay well that's a step in the right direction. As far as whether you should use die for when users are attempting something they shouldn't...well it really depends on the site, how much money is being invested in it/flowing through it, as to how much effort you want to put into it. For instance, with a site that collects user's personal info, especially financial info like cc numbers etc.., I would never let the user know that they are trying to do something they shouldn't do. All you are doing is giving them a clue of where your script's boundaries are.
  5. The point is not to just display an error message. The point is to log everything you can about what happened and where, and instead of just displaying an error message and halting the script completely, you do something else like redirect the user somewhere else, have your script try to complete some action a different way, etc... something other than just saying "you had an error" and then quitting. Going back to the online store: The goal is to get the user to buy something, right? Well if in the middle of shopping some error occurs, and all you have is a die('there was an error') ...what do you think the chances of that visit turning into a successful purchase is? I personally would immediately go somewhere else. How can I trust that your script won't somehow mess up my personal info, especially my cc info, if it's just dying on some random other error? And even if I somehow wasn't worried about that. What am I supposed to do next? Am I supposed to start over? What happened to the items in my shopping cart? Are they still there? Do I tell someone about it? Did my order go through or do I need to resend it? I don't want to get charged twice. There are a million wtf happens next questions, depending on what happened where, that simply dumping a "there was an error" and then quitting the script, just isn't good enough. Websites aren't built for the sake of being built. Not if you want to make money off it, anyways. So you can't just say oh well, something happened, display a message, the end.
  6. Thanks for stating the obvious. That's like saying you would save a ton of money by building your own site, if you know what you're doing. Or hey, if I bought my own parts and did it myself, I'd save a ton of money on parts and labor, building my own car. Well, duh. But how many people can say that? If the average joe could do things like that, then there would be no industry/jobs having to do with things like that. Even with Plug and Play technology making it a ton easier to install stuff (most people around here probably don't even know what it was like before Plug and Play), you can't just willy nilly point at something and expect everything to universally fit and work with everything else. Putting together a computer is still beyond average joe user's capability. Hell, even adding a single thing like more RAM is still beyond average joe user's capability. You probably laugh at that and say yeah right, because it's more or less a no brainer. If that is the case, I invite you to go down to your local bestbuy or busy street corner and conduct a survey, asking passersby how versed they are in putting together their own computer, or even installing a single thing, like RAM.
  7. You would abstract the error handling/logging into functions or a class or something and just invoke it. With your code, you have no idea what caused the error. Was it something with the script? Did the user cause it? On accident or purpose? It could be a legitimate bug in your system that caused your script to do that. User complains to you and you have nothing to look at, so you're stuck trying to reproduce the error with no info except for what the user happens to remember/tell you. Which, if you are still relying on just dumping a die statement to the screen like that, no offense, but you must not have much experience trying to get info out of users.. Same thing if user did it on purpose. Let's say he's trying to crack your system. You have no idea what exactly he's trying and where, because you are not creating any kind of paper trail with that. That paper trail can mean the difference between you finding a hole before he does and plugging it, and picking up the pieces from whatever havoc he caused, because he had all the time in the world to poke at your stuff and you were blissfully unaware.
  8. If you can't read the rules or even read the big bold letters right where you had to click to get this forum, I somehow doubt you're going to understand how to fix this.
  9. I'd say at least half of that pricetag is the fancy case it comes in.
  10. no. that's just the most common (and wrong) use for it. die (and exit) just tell php to stop the script. You can optionally have it do something on exit by putting it as an argument. The idea is that if something goes wrong, stop everything and display an error. The reason why that's the wrong thing to do, is that simply stopping your script will more than likely give your user virtual blue balls. In other words, that is not a way for your system to gracefully handle errors. For instance, let's say you have an online store. It's a multi-step process. halfway through the process, some error happens. So instead of your script saying "oh crap, something happened, let's save what the user has done so far, redirect to something else, try something else, notify someone, etc..." it just dies. User is like "wtf..." and leaves. You just lost a sale and even worse, you have no idea why.
  11. You know, when I'm doing my own coding, extra line visibility really isn't that big of a deal to me. I created it, so I already have the image in my head. But 99% of my work involves trying to figure swim around other people's code, so for me, the more I can visibly see at a time, the better.
  12. The problem is that you have your error reporting setting set to show every error message, even notices. Notices don't really break your code. All it's saying is that you are trying to make use of a variable that hasn't been previously assigned or declared. PHP is okay with that, but it tells you nonetheless, just as an FYI. The best way to remove them is to reorder your condition. Something like this: if (!isset($_GET['page']) { include('content/home.php'); } elseif ($_GET['page'] == 'links') { etc... That way the other conditions will only get evaluated if it's actually set.
  13. so...why have the die at all? Or just do the footer.html include before it...
  14. I totally sympathize about the not getting css thing. It took a really long time for me to really understand it, only to finally learn that there really isn't a whole lot to it, especially if you take advantage of something like firebug. From my experience, really, the hardest part about it is getting it to be cross-browser compatible, and even worse, cross-browser-version compatible. The fact that the same thing often does not work from browser to browser or version to version, really set me back on the css learning. I started and gave up so many times. My advice to you on that would be to just focus on one browser until the whole concept of css clicks. Then move on to getting it to work across the board. But overall, if you are stuck (and suck) at design/layout, but have a solid idea of the back-end stuff, why not just grab a free template somewhere? There are literally thousands out there, and thousands more, if you're willing to spend as little as $5.
  15. yeah I just actually turned my current monitor sideways and got about 75 lines out of it (I think it's a 19"). 1440x900 would actually be reversed since I'm turning it sideways, though. So I'm getting about 75 lines out of 1440px (Probably add another 25 or so if you count the menu and footer space for the IDE i'm using...about 75 lines of actual code being displayed in my IDE). So yeah..I guess just getting like a 30" monitor and turning it sideways probably will be the way to go. I get what you're saying about the whole peripheral noise after a certain amount, but I haven't found my personal limit yet. I just soaked up that 75 lines no problem.
  16. haha yeah I tried that but then it's too small to read for sure. About 10px is smallest I can live with, on a practical level. My monitor already sits about 3 feet away from me so I'm not really worried about it being too far/too small for bigger screens, as long as the fontsize is at 10px
  17. By better I mean faster. For some reason the more I can physically see at a time, the faster I can wrap my head around it. I've been working with like an 800x600 res or something forever with like 20 lines of text or something and I just started using a monitor set at 1440x900 and I'm it has like 40 lines now and able to take shit in faster so I'm thinking hey, let's go balls to the wall and get a huge screen with like 500 lines RAWR. Okay I will admit that 500 lines is probably too much, but seriously, I want like 100-150 or something.
  18. man, it's a mental thing. the more code I can physically see at a time, even if I have to move my eyes/head more, the better I can wrap my head around it.
  19. Yeah but stacking monitors creates a physical break in the text (the edges of the monitors). I was hoping to find a solution involving a really big screen so I wouldn't have that. I'm not by any means a rich guy, but I'm willing to save up and pay more for what I want, rather than settle for so-so just because it's cheaper. But I'm not willing to spend money on it if it's just not gonna work at all. So yeah...I'm not looking for bigger text. I'm looking for same-sized text, but more lines of text.
  20. yeah i thought about the swiveling my monitor sideways, but i want MORE. Seriously I want like 500 lines or something. I just want to know what all needs to be considered in order to achieve that. I know that the tv resolution counts, but I was thinking that with lcd/plasma, bigger == more resolution. And what really mattered was whether a) just because you have a big ass tv that can handle 10,000x8,000 screen resolution, does the graphics card care? Does the OS care? I don't want to spend money on it if for instance, windows doesn't support resolutions beyond like 1680 x 1050 or something. But I don't really know how all that works (hence the post).
  21. R4nk3d posted his suggestion when I was typing. His suggestion was along the same lines of mine, but I went ahead and posted anyway because I felt mine explained it a bit further. As far as your pages having similar titles, etc... that really depends on how you have it setup. Is it currently hardcoded onto each page, and you're wanting to be able to swap it out, depending on which page is loaded? What you would do is have a list of the info saved somewhere with the pagename (or an id) associated with each piece of data, and assign it to the var, based on that. You can store the information in an array hardcoded on your controller page (the page that is loading this stuff up), store it in a flatfile, or put the info into a database. Harcoding it on your controller page is the easiest to implement/explain, so I'll use that as an example for swapping your title out. But first, in order to make this efficient, you're gonna wanna back up to the actual page loading and write it a bit differently. Let's say you have 3 "pages" for your site: Home, About, and Contact. For the links, you would still pass a val=var, but you will want to pass an id specific to each page. You can make it anything you want, as long as its unique for each page. For simplicity, we'll just assign the name of the pages as the id's. So your navbar links would look something like this: <a href="somepage.php?id=home">Home</a> <a href="somepage.php?id=about">About</a> <a href="somepage.php?id=contact">Contact</a> somepage.php is your controller page. You can hardcode it, make the pathing relative, just leave it blank with the href saying "?id=3", or use $_SERVER['PHP_SELF'] (the goal is to reload the same page but pass the id so it knows what content to display). On somepage.php, you would look for the passed id, displaying relevant content (or displaying default content, if no id exists or if someone were to try and pass something other than an existing id number). So overall, your code would look something like this: <?php // listing of pages $allowed = array('home','about','contact'); // default page to display $default = $allowed[0]; // listing of content $content['home'] = array('title' => 'HOME PAGE','description' => 'some description about the home page'); $content['about'] = array('title' => 'ABOUT US','description' => 'some description about the about page'); $content['contact'] = array('title' => 'CONTACT US','description' => 'some description about the contact page'); // check to see if the id being passed by the link is in the list. If it is, assign it to $id. // if it is not (because it doesn't exist (first time page load), user changed it, etc..) , assign the default $id = (in_array($_GET['id'],$allowed))? $_GET['id'] : $default; // include the page include ($id . ".php"); ?> And then on for instance, the home.php that you are including: <?php echo "Title: " . $content[$id]['title'] . "<br/>"; echo "description: " . $content[$id]['description']; ?>
  22. Okay my goal here is to actually have higher resolution, so that I can get more lines of text on the screen in a document or editor or whatever. My screen resolution is set to the highest I can make it already, but I want more. Lots more. So I was thinking what if I bought a big screen plasma tv? Like, one that is like 3 feet high. BLAM! Okay here's the thing that I don't know, since I'm not a hardware expert or anything; maybe someone can tell me before I go drop a thousand bucks on this: If I go buy a big screen plasma/lcd tv that offers hdmi or dvi input, will it actually give me higher screen resolution options, like instead of 1440x900 px It will say like 10,000x8,000 px or something? Or will it just give me the same resolution options, and just show the same amount of lines, only bigger? Again, goal is to get more lines of text on the screen. LOTS more. Would I need to find a graphics card capable of higher resolutions? Are there even graphics cards available that are capable of that?
  23. all you have in your conditions are strings. So the only thing that is being evaluated is that it is a string. It evaluates true because it's just there. You would actually want to compare the string to something. Like for instance, if you have a link that passes a var=value, you would compare it to that. For example: <a href="somepage.php?id=blah">blah</a> and then when you click on it, on sompage.php, you would do: if ($_GET['id'] == 'blah') { // do something }
  24. Just to clarify what nrg said, + is a quantifier. It means 1 or more of something. You don't need it because {3,9} is the quantifier, meaning 3 to 9 of something.
  25. examples in the manual for date shows how to get dates from past/future. http://www.php.net/date
×
×
  • 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.