Jump to content

Simple Questions


Bman900

Recommended Posts

I am reading a PHP book right now and am on the part where you make a connection to a database. Here is the code am looking at:

 

<?php
$dbc = mysqli_connect('host', 'username', 'password', 'databasename')
or die('Error Connecting to MySQL server.');

?>

 

Now they tell me I don't have to close my first line statement as "or die" is still part of that said statement. But here is where they confuse me. This is the code where they tell me to run my query at:

 

<?php

$result = mysqli_query($dbc, $query);
// they close the statement here and bellow
or die('Error quering database');

?>

 

Wouldn't it be the same case here as "or die" is still part of my statement so technically I would not need to close the first line, right?

 

Sorry I know this is kind of lame but I want to learn something right the first time and I go deep into the lessons by rewriting code several times to remember it and I don't want to learn it the wrong way. Thanks:)

Link to comment
Share on other sites

There are ridiculous amounts of typos in programming books (At least in all the ones that I've read). You'd think they would've been proofread by at least a few people who have enough experience to catch these things..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.