Jump to content


  • Content count

  • Joined

  • Last visited

  • Days Won


justsomeguy last won the day on November 17

justsomeguy had the most liked content!

Community Reputation

972 Excellent


About justsomeguy

  • Rank
    More Human Than Human
  • Birthday 06/03/1979

Contact Methods

  • Website URL
  • ICQ

Profile Information

  • Location

Previous Fields

  • Languages
    Focusing on PHP and JavaScript

Recent Profile Visitors

273,274 profile views
  1. SELECT JOIN - A Failed Query

    Yeah, I wouldn't think that the aliases would expand over the union because each of those select queries stands alone.
  2. Web Standard X11 (Primary Digital Named Colors)

    I just don't agree with that. Color names are over-rated in a global world. Instead of trying to figure out what someone means when they tell me they want the background to be dunkelgelb, they could just tell me to use #938200 or whatever the specific value is. Mathematics is the only universal language we have. Trying to tack on words in various languages that everyone doesn't even speak or understand as a replacement for a concise definition is not progression, it is regression.
  3. form validation

    You hash the password prior to inserting in the database, but you add it to the database like any other value. You wouldn't insert the plain text password from $_POST, you hash that password, get the hashed value, and then insert that hashed value into the database. I would recommend that you learn how to use PDO for the database work though. You need to use prepared statements when you're putting data in a query, and PDO is just easier and less complex for prepared statements than mysqli. http://php.net/manual/en/pdo.prepare.php http://php.net/manual/en/pdostatement.execute.php
  4. What does this code do?

    It just sets a variable to another value. That value comes from $_GET, which holds all of the values that were included in the URL.
  5. SELECT JOIN - A Failed Query

    I misread what you wrote, I thought you wrote "there is no such thing as scope". Yes, SQL queries have a scope.
  6. SELECT JOIN - A Failed Query

    Yes, you need the same number and type of columns returned. You don't need to use the same table aliases necessarily, but it makes sense to use the same column names. That's not a correct assumption, if you remove the table aliases but keep them in the list of columns you'll get an error indicating that it doesn't know what p or c is. In that specific example, I don't think so, I think those aliases only apply to the select query where they are used. I could be wrong about that though, you might be able to use one in the other select query, but I don't think that would work. Yes. It won't, it's just being explicit about what you're asking for. If you wanted each ID from the two tables separately, for example, you should give each one a unique alias instead of returning 2 columns with the same name. If you change the data type of a column and there is existing data, MySQL will attempt to convert the data to the new data type. There are various rules for converting data between types. This is also called casting. You can also explicitly convert data during a SQL query, there are functions to do that. Those are the same functions that MySQL would use if you change the data type of a column.
  7. loop input for each string

    Well, what do you want to do? Right now you're removing commas and spaces, what do you want to do with that value? If you don't want to remove commas and spaces, what do you want to do?
  8. Web Standard X11 (Primary Digital Named Colors)

    Do you think the links you posted are incomplete, or something? Why are you asking for additional resources? It looks like the 145 names are all there are. You can read more about it here: https://en.wikipedia.org/wiki/X11_color_names Like that article mentions, this list of color names has nothing to do with the W3C, it was created for the X Windows system. The W3C just recommended that web browser vendors implement support for them (after Mosiac and Netscape supported them, and thus a lot of people started using them in creating web pages). There aren't going to be any additions or changes to that list that I would expect, that's 30 years old. Other than as a marketing aspect, there's no reason to use color names when we can use color definitions instead. There are 145 named colors out of the 16.77 million colors in the 24-bit color space, so that percentage should tell you how useful we find naming colors. 4K is a marketing term regarding the resolution, not the color depth. 4K monitors are monitors where the larger dimension is close to 4,000 pixels (usually just under). It doesn't relate to how it displays colors, I'm sure it's still using the same 24-bit color space that everything else uses. It will go away whenever browser vendors decide to drop support for named colors in CSS. That's probably not going to be any time soon. But in the same vein, X11 color naming is also not changing. Like I said, it's 30 years old and hasn't been changed in a long time. There's no reason to change it, it might be "fun" for artists to use names when referring to colors, but computers aren't artists, they're machines. A list of 145 names is far less useful to a programmer than the ability to specify any one of 16.77 million colors just with a simple 6-character definition. When I'm working with a client and they want to specify what their color scheme is, I get that list of colors as RGB codes, not a list of named colors. All of this discussion also glosses over the fact that differences in displays and printers mean that the same color isn't always going to look exactly the same on everything. You can change the color settings for any monitor, there's no guarantee that any display or printer will represent any color exactly the way you intend. That can be frustrating for an artist but that's reality.
  9. SELECT JOIN - A Failed Query

    Well yeah, you're asking for different data sets. One of them was for ID 10, and this one is for ID 9. That ID should change in the query depending on whatever your primary record is. At this point I would specify the columns you want from each table. e.g.: SELECT p.id, p.usertype, p.username, c.userbio FROM parent_table AS p LEFT OUTER JOIN child_table AS c phpMyAdmin is showing all of the columns from both tables because it's accessing the row differently than you're doing in your code. In your code, $row['id'] only refers to a single value, phpMyAdmin is looping through the columns and showing them that way. There's no reason to return the duplicate ID and usertype columns though (there's also no reason to store the usertype in more than one table at all, it wastes space and creates a consistency problem if you update one table but forget to update another one). Like they say, you can either take the time to do it right or make the time to do it over. People often choose the latter, even though it's more difficult to unlearn and relearn things like this.
  10. MySQL - Columns based on 2 Columns by Row

    You need to use a join, not a union. You join the tables on their common ID and return the values you want from each table.
  11. Excel Export

    You have a Workbook and Worksheet class, if you look up the documentation for those classes you should find the list of methods you can use to change them.
  12. loop input for each string

    That inner each shouldn't be there, you're trying to loop over everything that has the ID "input" but you should only have 1 element with a certain ID. I'm not sure what you're really trying to do though, you split something up on commas (followed by a space), then loop through those values and add each one to a string. So all you're doing is removing the commas and following spaces.
  13. form validation

    Don't bother passing a salt to password_hash, let it generate one. You're also not hashing the password they entered. Other than that, I don't see the point of using htmlspecialchars in that test_input function, other than that the only thing you do with the form data is print it on the page. If you're going to store it in a database you don't need to do that. I also don't like the name of test_input, because it doesn't test anything. The regular expression to validate the password is also a little bit overboard. If you want to verify that it contains at least one uppercase letter, one lowercase, one digit, and is at least 8 characters total that's fine, you don't need a big regular expression to do that. I hate it when some website rejects my complex password because it doesn't fit their arbitrary rules.
  14. SELECT JOIN - A Failed Query

    Now we're back to database design. I don't see a reason for you to design the database like you did, one-to-one data should go in the same table. You shouldn't need a join at all. There's another problem I just noticed though. The two queries that are being unioned are the same query. There's no reason to do that, they're going to return the same data. That's not what I was describing when I suggested that query format, the queries that I union together are not the same. One of them selects the primary row and one of them selects the related rows. That suggests that your PHP code is incorrect somewhere. phpMyAdmin is a PHP program, it's probably using PDO or maybe mysqli, it should be no different than your own code. If you're getting different results then it sounds like your code is doing something wrong.
  15. SELECT JOIN - A Failed Query

    I mean you need to group the queries to make it explicit what you're trying to do: (SELECT * FROM parent_table LEFT OUTER JOIN child_table ON child_table.id = parent_table.id WHERE parent_table.id IN(SELECT ref FROM ref_table WHERE ref_table.id = 10)) UNION (SELECT * FROM parent_table LEFT OUTER JOIN child_table ON child_table.id = parent_table.id WHERE parent_table.id IN(SELECT ref FROM ref_table WHERE ref_table.id = 10))