Note that there are some explanatory texts on larger screens.

plurals
  1. POunderstanding variables and scope
    text
    copied!<p>EDIT*** my question was a bit hard to understand...let me try again.</p> <p>I'm having a problem understanding variables and <em>the way they execute their value</em>.</p> <p>for example.</p> <p>if I say</p> <pre><code>$var name= 'mike'; </code></pre> <p>then if I test the page nothing will show because nothing on the HTML is requesting the value of mike.</p> <p>if I did </p> <pre><code>echo $name; </code></pre> <p>then the page would simply show mike.....</p> <p>that said, if i now do this:</p> <pre><code>$connect2db = mysqli_connect('values here'); if(!$connect2db){ die("error connecting to the database" . mysqli_error);} $db_query = mysqli_query($connect2db, "INSERT INTO email_list(email, firstname, lastname) VALUES ('$email', '$fname', '$lname')"); </code></pre> <p>for inserting these values from a form to the db, I don't understand how the connection and the commands to the db are being called and put into play because to me</p> <p>$connect2db equals to "those commands" but nothing is calling it. all $connect2db equals to literally is the instruction to take once its called into play.</p> <p>where on this chunk of code is the connection being called/put into play? where on this code block is the code being called into action(like the echo above calls $name to be put into action to display its value"???.</p> <p>I don't see anything on that connect2db variable that calls its action/connection properties to work.</p> <p>like for example if I was to say </p> <p>pseudo</p> <pre><code>if(is true){ this.$db_query; } </code></pre> <p>this I understand, this to me means that IF something evaluates to true, do the thing in the middle..</p> <p>with the original first code block, its like the variable is naming and calling itself at the same time.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload