-
Posts
15,266 -
Joined
-
Last visited
-
Days Won
431
Everything posted by requinix
-
Adding the level should be as simple as UPDATE table_with_the_planets SET whatever_thing_youre_updating = whatever_thing_youre_updating + column_with_the_levelI have no idea what any of this has to do with rarity, or really why you need to "add what level the planet is" in the first place.
-
No. Don't do it. That's bad. You have an array already and it has everything you want. Just use $array[1] and [2] and so on. Dare I ask... What's this array, why does it look like you have 1-178 sorted like strings and partitioned into those sub-arrays, and why do you think you need to put them into separate variables?
-
Because whenever you want to run a query, you'll find yourself going to some other place in code where you do a query, copying the code there to connect to the database (because you don't remember the server or username or password), and pasting it in the new code. And if anything there changes, like if you moved to a new host, then you'd have to go through the code you have, change the information, then copy and paste the changed code to everywhere else you need. With OOP you put most of that code into a class. There's still some code that you write/copy elsewhere, but there's less of it and it's much less likely to change in the future.
-
You mean procedural and object-oriented code for interacting with databases? Because databases themselves are... neither. Question doesn't make sense. Procedural tends to mean a lot of copy and paste, with all the bad things that can mean. Object-oriented makes nicer code.
-
PHP won't just make something null. It looks like the only way to change $_db is using set_db_adapter(). Have you checked whether it's being called with a null $db_adapter?
-
It seems like you simply have the wrong username and/or password. Is there a place where you configure user accounts? Does it say that actual username? Sure you have the right password? You are connecting to the database from code running on hosted site, right? Not locally?
-
Reverse words in a sentence without using PHP functions
requinix replied to Dota2's topic in PHP Coding Help
I wasn't trying to I wouldn't use my own code for real because it's not clear how it works. There's something to be said for code that's longer but easier to understand. -
And the code for Session_DB_Handler would be...
-
Have you considered showing us the code so we don't have to make blind guesses?
-
Reverse words in a sentence without using PHP functions
requinix replied to Dota2's topic in PHP Coding Help
No string manipulation functions? No functions at all! Unfortunately it turned out much simpler than I thought it would. $input = " this is phpfreaks"; $output = ""; $word = ""; for ($i = 0; @$input[$i] != ""; $i++) { if ($input[$i] == " ") { $output = " " . $word . $output; $word = ""; } else { $word = $word . $input[$i]; } } $output = $word . $output; echo "[{$output}]\n"; [phpfreaks is this ] -
Fatal error: Call to a member function query() on a non-object
requinix replied to vet911's topic in Applications
You've got a try/catch up there at the top that will show an error message if PDO had a problem. Was there an error? -
passing array to PDO bindParam giving me error
requinix replied to venkatpvc's topic in PHP Coding Help
The problem is (due to emulated prepares, but is) moot: you cannot use prepared statements there. They are only for passing actual data into a query - you can't use them for things like CREATE TABLEs. -
Fatal error: Call to a member function query() on a non-object
requinix replied to vet911's topic in Applications
Not sure what a hostname has to do with any of that code... How about posting the rest of it? Be sure to include the bit where $dbh gets defined. -
why is my script keep repeating multiple times? jquery
requinix replied to et4891's topic in Javascript Help
It's logging the value of colorHolder, which is a class name from some element. The code is pretty clear about that. Are you sure there isn't something else modifying that variable? -
why is my script keep repeating multiple times? jquery
requinix replied to et4891's topic in Javascript Help
Adding up? Multiplying? -
So you're saying that you don't have any other sort of redirection code in place anywhere, but if you go to absolutely any "file" that has two underscores in it and no trailing slash, and does not exist in any form there whatsoever, you are being redirected to the same location but with the trailing slash? So if you go to /abc_def_ghi then you get redirected to /abc/def/ghi/?
-
Well, it's like your .htaccess says: RewriteCond %{REQUEST_FILENAME} !-d"don't rewrite if the target is an existing directory". Which is a good idea to do: you probably shouldn't have a file and a directory with the same name.
-
Use a foreach loop on $site. Each value will be an array that looks like the $anyvariable you want.
-
One of them. You escape one of them. The one that you are using for the string delimiters. Not both of them.
-
The backslash problem is because you're putting backslashes in places that don't need it. Since the backslashes aren't necessarily there, PHP keeps them in place thinking that you wanted literal backslashes. Don't use them for single quotes in a double-quoted string, or vice versa. Whatever you're experiencing is not due to PHP. I'm more troubled by the "3000 random characters and it worked" statement, which must mean something besides other than what those words literally mean. This is probably the time when you should be looking more closely at the API itself. If the code returns null then look to see under what conditions it will return null. Trace it back up to the actual API call (or whatever) and find out exactly what's happening. Because poking and prodding with different strings here and there isn't making much progress.
-
What quotes?
-
Fatal error: Cannot redeclare PHPMailerAutoload()
requinix replied to VanityCrush's topic in PHP Coding Help
I'm a little confused now. You agree that require_once() is the best solution, but are doing something else instead? Calling header() will not stop your script. It'll keep executing. So if all you did was add that line then the error would keep happening. 1. email_users() should be only about emailing users. It shouldn't have to do anything with a redirect. 2. The redirect should be in the calling code after all, because it's the calling code that knows that it was a web request in the first place and that the user should be sent to that page when successful. 3. Changing all your include/require()s that are for files which define classes or functions to use include_once/require_once() instead will solve your problem. Though you should still look into why the file was included twice as that could (could) be a symptom of another problem. -
Obtain and Export IP Address to .txt file
requinix replied to reubikcube2013's topic in PHP Coding Help
That's pretty specific. Have you considered learning PHP and writing the code yourself? -
Your first regex is way too permissive. '#(http://)(www.)(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})#x' [^/]+/.+/Regexes are greedy: they will match as much as possible and only backtrack if they encounter a problem matching the rest of the pattern. [^/]+ will match anything up until the next slash (which is the slash in the first "") then a slash, then any amount of anything which will take it all the way to the end of the line, then backtrack until it finds another slash (which is the last slash in the MP3 URL). Then 11 characters will match "leonhardt_s" and the MP3 regex is left with just "kaar_2015.mp3". The easiest modification is to make sure the regex stops at whitespace too, not just a slash. The first portion will fail because there isn't another slash to find, the second portion won't match, and the third will. However the third is way too permissive as well because of the .*. You can change that to match anything but ?, &, and whitespace just in case. '#(http://)(www.)(?:youtube(?:-nocookie)?\.com/(?:[^/\s]+/.+/|(?:v|e(?:mbed)?)/|[^?&\s]*[?&]v=)|youtu\.be/)([^"&?/ ]{11})#x' By the way, the HTML in your $replacements[1] is wrong. And there's no point to using the /x flag if you're not using regex comments.