When you use a lone variable as a condition, you're checking to see whether the variable holds a non-truthy value, evaluating to the boolean value FALSE, or if it instead holds a truthy value, evaluating to the boolean value TRUE.
> Is it just a short way of saying "if $flip == to the first value of rand()"?
Yes, sort of, but only because 0, a non-truthy value, is passed in as an argument here. If they used rand(2,3), the loop would never end because neither 2 nor 3 are non-truthy values; $flip would always be TRUE in that case.
http://php.net/manual/en/mysqli.query.php
mysqli_query returns a mysqli_result, which is what is being output by print_r. You're missing a step:
<?php $id = $_GET["id"]; $query = 'SELECT article FROM articles WHERE id=' . $id; $link = mysqli_connect('127.0.0.1','root', 'password', 'PENTETEST'); $data = mysqli_query($link, $query); while($result = mysqli_fetch_row($data)){ print_r($result); } ?>
$addons would be a different variable than $row['addons'], but I am guessing that is just a typo or you assigned it elsewhere since you said it is an array.
This works for me with a dummy fetch_assoc function returning the data you provided to slowmode1:
. '<li>'.join(', ', $row["addons"]).'</li>'
If this is what you've tried and it's still not working, check all of the rows you are trying to print and look at the addons column. In theory it should always be an array with 0..n elements, but since you have a NULL variable to represent "no discount", I am wondering if "no addons" is represented by a NULL variable in another row. This would cause the invalid argument error.
To account for this, you could check first before trying to render that row:
function renderAddons($addons){ if(isset($addons) && is_array($addons)){ return join(', ', $addons); } }
(and then change the row["addons"] line to call the render function:)
. '<li>'.renderAddons($row["addons"]).'</li>'
Uploaded demo here: https://repl.it/@morrow/DifferentLargeDos
What's the actual question? If it's how do I know when 28 days from X date is, use mktime and date .
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+28, date("Y"));
It would depend on how the file is being opened and content is being added. I am assuming you are using the fopen() function to write to the file. In this case once two users open the file they will receive a copy of the content at the time of opening it but once they save it it may lead to data corruption or loss as they may overwrite each other (depending on the order of save) or cause data corruption.
There are a few ways to deal with this,
1. one would be to use flock() to ensure that only one person is writing to a file at a time.
2. When it comes to adding and removing from a text file with multiple users the process becomes more complex. If this is your goal you may be better off going for a database implementation.
Well--that depends on a lot of things. Since you didn't post any code, it's very hard to help you. Here's is a good, basic example on how to create a form and insert the data into the database. It should be more than enough to get you started: https://www.ionos.com/digitalguide/websites/web-development/use-php-to-insert-information-into-a-mysqlmariadb-database-from-an-html-form/
Sorry, I'll try to be more specific. I figured too much info instead of not enough.
I have a Host Gator account to host my site files. I have this - https://stripe.com/docs/tutorials/charges and my issue is I'm not sure what to do with it.
Queues are awesome. I'm going to assume you are talking about message queues like rabbitMQ and SQS, if not correct me.
Things to watch out for (or things which have caused me pain in the past)
I've used the following queues in production SQS, RabbitMQ and a simple ZMQ queue.
For a first time round I would suggest something like iron.io or SQS both are really go services and have free tiers for learning.
As skaterape said laravel handles queues nicely and there is a video on laracasts about using iron.io Here to help you get started.
If you really want to host your own queue beanstalkd is excellent to start with, it has a simple api, is well documented and has tons of resources/tutorials.
If you are looking for something really amazingly cool and super interesting to use checkout ZMQ, it's epic. You can do so many things with it but you'll need to basically roll your own queue from scratch.
You should join them in one query using MYSQL JOIN syntax, check the active record documentation.
Have you considered using ajax on the client side? In my application I use a time token and the client queries the server for any new information after that token. Server to client can be tricky because the client can go away at any time.
I haven't worked with websockets myself since I have to support older browsers and http://caniuse.com/#feat=websockets says no.
If you want to start down websockets and have questions I am sure somebody can help answer them here.
+1 for Head First Design Patterns. Even though the code examples are in Java there is more than enough similarity between OOPHP and Java to make them relevant and understandable.
The first chapter or two of PHP Object - Oriented Solutions by David Power was one of the better books I read when making the jump to OOPHP, and now reading through PHP Advanced and Object Oriented Programming, which is a decent read. Issue is everyone will always point you to different resources.
2013 edition.
Yea it is still good. OOP hasn't really changed much. Once you get the concepts you can typically apply it to any programming language.