-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Can you post a commit graph? Looks like one of the things shown here. Here's one from GitHub: [edit] The black line is master. Didn't need to redact that.
-
Did you make any commits to develop once you forked from master?
-
No no, you can have multiple branches. You're supposed to. Mind you, if it's just you working then there's a good chance you'll just work on one branch until you're done, merge, and then start a new branch. Or maybe you have one, decide you want to do something else for a while, and start another one. But multiple branches is definitely a thing. I meant you can only have one checked out at a time. In the working directory. If you want to work on a second branch then you either (a) commit/stash your current stuff and switch branches or (b) clone a whole new second repository and do the second branch on that. The former is the normal way of doing it, and while the latter isn't necessarily wrong it can make things confusing (like "which clone was I doing $branch with?"). ...No? I don't know what you're seeing but when you do a merge/pull you're only updating the branch you have checked out. Fetch can update all remote branches but any local branch remains where it was.
-
fetch() will return an array. If your placeholders use the same names as the returned columns (hint: they don't) then that would work. fetchAll() will return an array of arrays. One, you cannot do a while loop on it because you will keep executing fetchAll() every time. Two, you can't execute() with an array of arrays. Use the question mark placeholders so they don't have names, then the array from fetch(). Making damn sure that you get the right columns in the right order. Which is not something I would leave to chance. $select_results = $pdo->prepare("SELECT * FROM cyptokeys"); $select_results->execute(); $header = $select_results->fetch(PDO::FETCH_ASSOC); if (!$header) { // no results? abort } try { $insert_stmt = $pdoyd->prepare( "INSERT INTO cyptokeys (`" . implode("`, `", array_keys($header)) . "`) VALUES (" . implode(", ", array_fill(0, count($header), "?")) . ")" ); } catch (PDOException $e) { // do something and abort } $row = array_values($header); do { $insert_stmt->execute($row); } while ($row = $select_results->fetch(PDO::FETCH_NUM));
-
Normally you work on one branch at a time. If you want your master to be up-to-date then you would do a fetch/merge (or a pull which is the same thing). Actually, for something like master, you should never be committing to it anything besides merges from other branches so I do a fast-forward merge. Normally you would then, later, decide you want to work on the develop branch. You check it out, do a merge, resolve conflicts, and begin working. No, you cannot merge into multiple branches at once with a single command. The main reason would be the difficulty with conflict resolution. What you can do is script it yourself: fetch, for each branch { checkout, merge, do something in case of conflicts (eg, pause and wait for the user to resolve), and commit }
-
Don't use .onclick to set a function. Are you using a Javascript library? If so, what? If not, any reason why not?
-
Stick the "http://" in there too.
-
What's the structure of the data being returned, and what is your code to load it into objects?
-
Looks like you have arrays within arrays. Do two foreachs. And figure out why you thought there was only one array of stuff because that suggests you aren't completely aware of what is going on.
-
Let's be clear: I'm only talking about using the value within a Location header. Nothing else. Yes, kinda, PHP_SELF and REQUEST_URI can be "spoofed" in the sense that someone can manipulate the data. They can forge a request using any valid URI they want to your server. However if they use an invalid URI then the server will reject it. Immediately. Because it's invalid. So if your PHP has the value of REQUEST_URI then that necessarily means the URI is valid: the server accepted it and figured out that it should be routed to your PHP script. Is it exactly what you want? Not necessarily: odds are someone could add new query string parameters and your script wouldn't care, for example. However the resulting URI must still be valid, which is why you can put it into a Location. Can you do the same with PHP_SELF? I don't remember if it is a URI-decoded value. I think so. But it doesn't include the query string so you wouldn't want it anyways (at least not when you could use REQUEST_URI instead, which does).
-
htmlspecialchars() is only for putting stuff with special characters into HTML. As the name might suggest. The REQUEST_URI must necessarily be safe if your web server was able to accept it and have PHP execute properly for it. The Location header itself doesn't have any special structure besides "Location: URI".
-
Not both at once. One at a time. Because if you read the documentation for mysqli_query() you would know what the arguments to it are and that it only does one query.
-
mysqli_multi_query() is not meant to work that way. Use the regular mysqli_query() and just call it twice for the two queries. Even better would be to use transactions: start transaction, do first query, rollback and abort if it fails, do second query, rollback and abort if it fails, commit.
-
Server timezone, user timezone, user date format ...
requinix replied to Andy_Kemp's topic in PHP Coding Help
If you're looking for a critique, use the OOP methods instead of the procedural functions. Like function format_timestamp($config, $ui, $timestamp) { $time_zone = (is_logged_in($ui) && $ui['time_zone'] !== 'default') ? $ui['time_zone'] : date_default_timezone_get(); $date_format = (is_logged_in($ui) && $ui['date_format'] !== 'default') ? $ui['date_format'] : $config['default_date_format']; $date = new DateTime('@'.$timestamp); $date->setTimezone(new DateTimeZone($time_zone)); return $date->format($date_format); } A Unix timestamp does not have timezones. It's the same number at the same time everywhere in the world. Your function does the same thing that a single call to time would. -
What parse errors? Line breaks are totally allowed in XML. <orderComments>If its possible to get an autograph from the captain and the crew to my husband Amadeus it would be great. He just loves the show on tv and is also a fisherman here in Sweden. Thank you Anna</orderComments>If you called nl2br on the comment and then put it into XML, that would not work because would be interpreted as an XML node when you didn't want it to be.
-
Yeah... I didn't mean for you to put literally "Williams R" in the query. It was an example.
-
a) Instead of using fullname LIKE "%Williams R%" make it do fullname LIKE "%Williams%" AND fullname LIKE "%R%". b) If the search has two "words" make it do fullname LIKE "%Williams%R%" OR fullname LIKE "%R%Williams%". Three would probably "Last F M" so that would be OR fullname LIKE "%F%M%Last%". That lone "R" sucks.
-
Okay, so... what issues? Are you trying to show the comment in HTML and you're not seeing the line breaks? Use nl2br. If not that, what?
-
remove malicious php from image uploads with IMagick
requinix replied to bonecone's topic in PHP Coding Help
Those are the same thing. Unless you have a weird definition of "display images". -
Getting only last date of transaction with join
requinix replied to I-AM-OBODO's topic in MySQL Help
I can't speak much to the performance, but I would expect a non-subquery solution to be faster and more efficient than a subquery solution. If you needed other tables (with a one-many relationship), or if you wanted other aggregate (eg, MAX) data at the same time, then subqueries would be the way to go. Mostly because there aren't really any other alternatives. -
Moving from Java to PHP .... A good career move?
requinix replied to venkatdabri's topic in Miscellaneous
Why not both? Focus on Java but learn PHP too. Maybe more languages. Diversify your skills. -
+1 to error_reporting. Is $conn defined?
-
This might be turning into a "how do I do $x in WordPress" question... How much did you copy and where did you put it? Do you know what $post is? Is it coming from the imported data you/WP got from the XML? That code you have now: what does it do now and what is it supposed to be doing instead?
-
I don't see the connection. What does post metadata have to do with an XML feed? I thought you were trying to load an XML feed and display data from it? What does WordPress have to do with it?
-
It's not that simple. Sessions are driven by cookies, and cookies are tied to domains. Each of the four domains will have its own session* because they each have their own cookies. And you cannot set a cookie for a different domain. There is a way to do it with sessions, but it sucks. Easier would be to reuse the redirection. Um... Take this code with a grain of salt: I feel like I'm making a mistake or two somewhere. First, move the redirection stuff out of PHP and into the web server configuration. It will be faster and more efficient if PHP doesn't get involved in the process. // vhost config (best) or .htaccess (okay) RewriteEngine on RewriteCond %{HTTP_HOST} !=www.WEBSITE_URL_HERE.co.uk RewriteRule ^ http://www.WEBSITE_URL_HERE.co.uk/redirect?site=%{HTTP_HOST}&to=%{REQUEST_URI} [L,R=301]If the host name doesn't match, redirect to the right hostname and pass along the original hostname and the original URL.This introduces a new page dedicated just to supporting this stuff. Don't need to bog down the rest of the site with checks if you don't need to. Then write that new page. It doesn't have to output anything because it will always redirect the user somewhere. $sites = array( 'WEBSITE_URL_HERE.com', 'www.WEBSITE_URL_HERE.com', 'WEBSITE_URL_HERE.co.uk', 'www.WEBSITE_URL_HERE.co.uk' ); if (isset($_GET['site']) && in_array($_GET['site'], $sites)) { // session_start(); if it hasn't happened yet $_SESSION['site'] = $_GET['site']; } if (isset($_GET['to'])) { // need to validate it so people can only be redirected within this website $to = $_GET['to']; $todata = parse_url($to); // don't allow something with a hostname. both "http://example.com" and "//example.com" will do that if ($todata && empty($todata['host'])) { header("Location: {$to}", true, 307); exit; } } // if we're here then this page isn't being used correctly header("Location: /", true, 307); exit;Finally there's the logo function. Basically the same as before. function logoSwap(){ switch(isset($_SESSION['site']) ? $_SESSION['site'] : $_SERVER['HTTP_HOST']) { case 'WEBSITE_URL_HERE.com': return "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png"; case 'www.WEBSITE_URL_HERE.com': return "WEBSITE_URL_HERE/wp-content/uploads/2016/01/logo-red.png"; case 'WEBSITE_URL_HERE.co.uk': return "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png"; case 'www.WEBSITE_URL_HERE.co.uk': default: return "WEBSITE_URL_HERE/wp-content/uploads/2015/09/logo.png"; } }Oh. I renamed the thing from "url" to "site" because it's a bit less ambiguous that way. Probably should go with "original site" or something even clearer. PS: The logo with the different domain names doesn't make sense anymore. If someone goes to domain1.com then they'll be redirected to domain1.co.uk but see the .com logo. That's confusing. * Or two. The www and non-www can share cookies if the session cookie parameters are configured properly, but the .com and .co.uk definitely cannot.