Jump to content

Zurev

Members
  • Posts

    260
  • Joined

  • Last visited

Everything posted by Zurev

  1. if ($line['hits'] < 10 || $line['hits'] > 1) Less than and greater than are your friends, the double pipe | means OR. http://php.net/manual/en/language.operators.logical.php
  2. You need a join, whether it be using the join keyword, or using the traditional method: update #__jrleech, jos_users u, jos_roxsuite_membership_history m set `published` = '1' where `id` = '".$row->id."' and u.id = m.id; That definitely won't work, since it's hard to understand your actual question, but that should give you some guidance as to pulling values from multiple tables.
  3. No one suggested the use of is_null? I mean empty works, but also if it's equal to 0. http://www.php.net/manual/en/function.is-null.php
  4. Assuming the users are returned in an array, array_merge would do exactly what you're looking for.
  5. Checking if an already existing row is in the database before inserting an identical one is child play? Pft.
  6. Why not check for a row with the same values, if it exists, don't insert the row. Otherwise, insert it.
  7. $query = "SELECT DISTINCT property_functionsexperience FROM #__users_profiles WHERE published = '1' ORDER BY property_functionsexperience ASC"; $functionsexperiencelistgeneral=doSelectSql($query); foreach($functionsexperiencelistgeneral as $words) $property_funcexperilist=$words->property_functionsexperience; $wording = explode(', ', $property_funcexperilist); $wording = array_unique($wording); foreach($wording as $funciex) $funcexpList .= "<option value=\"".$funcexi.','."\">".$funcexi."</option>"; $funcexpList .= "</optgroup>"; } $funcexpList.="</select>"; $output['FUNCEXPLIST']=$funcexpList; That should work, you may want to think on making easier to read variable names, and ones that better describe what you're doing, otherwise later on it's going to be hard for you to remember what's going on.
  8. mysql_query creates a resource. You're updating where username equals resource id whatever. So: //record date of most recent login $result = mysql_query("SELECT username FROM users WHERE user_id ='".$_SESSION['userId'] . "'"); $theUsername = mysql_fetch_row($result); $theUsername = $theUsername[0]; $dtCreated = date('Y-m-d'); mysql_query("UPDATE users SET lastvisit=('$dtCreated') WHERE username = $theUsername"); Give that a try.
  9. First thing I would try is to do it with fopen instead of file_get_contents - just to SEE if it works, in which case you've narrowed it down to it being file_get_contents' problem. OT: Why do you seem so focused on file size of a cms? It really doesn't make a noticeable difference, look at the top CMS's, even things like WP are 8+ megs.
  10. PHP is interpreted line by line, I don't believe you can declare something below it and have it work. Also, you're setting your cookie to exist for 5 seconds, might want to check on PHP's setcookie. http://www.php.net/manual/en/function.setcookie.php
  11. The site doesn't look extremely complicated, but even so, without knowing the system it would be difficult/time consuming, and without knowing PHP on top of that, it would definitely take a while. Also it seems part of it is powered by SMF, which could complicate things, though if it's an SMF file you overwrote, you can try and replace it with the same file from that version of SMF.
  12. First question, why are you passing MYSQL_ASSOC as a second argument to mysql_query(). mysql_query() takes the query, and an optional second argument as the link identifier, which that is not. If you're looking to fetch it as an associative array, it's already doing that with mysql_fetch_array, though you could switch it to mysql_fetch_assoc. Though that most likely isn't the issue, I wonder if it's causing any problems.
  13. Syntax highlighting is your friend! Variables in PHP must start with a letter or an underscore! Fix that and see if you're still having troubles.
  14. Right, you can for variables..but not constants: $variable = 'Hello World'; echo "Guess what? {$variable}"; // Guess What? Hello World
  15. I believe you'd have to concatenate it...like echo "This is my constant". CONSTANT; But what's the big deal of having to use concatenation?
  16. Do the same thing, and put it in a loop. To be honest, these are extremely basic questions, I think you should take a good look at: http://www.php.net/manual/en/language.control-structures.php before going further.
  17. if (empty($row['name'])) { echo 'n/a'; } Reason being, empty is a function. If you wanted to compare it you could do is == "". Take a look at http://php.net/manual/en/language.operators.comparison.php Don't get tripped up on =, ==, ===.
  18. Also I'd like to note, as you get farther into your learning experience, you'll start to do some form of hashing passwords, whether it be MD5 or SHA1, so escaping the password field will actually be detrimental if anything, since it could alter what the user had typed in, and you won't have to worry about injection since it will be an alphanumeric hash.
  19. Why the slashes in the middle of the query? Try using this and see how it comes back: $user_name_check = mysql_query("SELECT * FROM users WHERE user_name = '" . $_POST["user_name"] . "' AND password = '" . $_POST["password"] . "'");
  20. Try: echo realpath("../../"); If that doesn't work, take a good look at the php functions: getcwd(); dirname(); basename(); realpath();
  21. I mean if you think about it, the {replace} template systems are not amazing, but they work pretty well. However you should only have to modify your template files if you want to change the look of something. This system, if you added a new game, you would have to add another {game646}. Parsing all that template file with file_get_contents (assuming) is a bit of overhead, adding regular expressions into it is going even farther. If you just loop through a single template called something like 'eachSubgame.tpl' and display it once for each subgame, it would definitely be better.
  22. Just make one template file for each subgame, and loop through that template file and display it once for each subgame. I believe that's how software like phpbb does it when they use these sort of templating systems.
  23. Why don't you make a real getter instead of one for a specific variable, so you could access all class properties from one method? class whatever { protected $_stuff1 = 'stuff 1'; protected $_stuff2 = 'stuff 2'; public function get($key) { return $this->$key; } public function set($key, $value) { $this->$key = $value; return $this; } }
  24. It shouldn't be too far, the expressions should be similar if not the same, I never messed with any POSIX though. So for example, this would check if it's a string 1-8 characters of only a-zA-Z: $isValid = preg_match("/[a-zA-Z]{1,8}/", $_GET["style"]);
×
×
  • 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.