Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //connection parameters
- $hostname = 'localhost';
- $username = 'tbcj857';
- $mysql_pass = 'm2d59';
- $database = 'tbcj857';
- //connect to mysql
- $conx = mysql_connect ($hostname , $username , $mysql_pass)
- or die("Can't connect to MySQL" . mysql_error() );
- //connect to specific database
- mysql_select_db ($database)
- or die("Can't select that database" . mysql_error() );
- return $conx;
- }
- //Show a whole blog post on the page including the author, the blog title and body text
- //therefore i need to return data from
- dbConnect();
- // include some php
- include 'php_include.php';
- echo '<div style="background:#ecc;border: 4px solid #dbb;">';
- echo '<p>- Trying to echo the variable $a, defined in the php include: <br>';
- echo '<pre>$a is: ' . $a .'</pre></p>';
- echo '<p>- Calling the function hello(), defined in the php include: </p>';
- hello('admin');
- // include some html
- include 'html_include.php';
- ?>
- <h3> this is in the body of the main file</h3>
- <blockquote>
- <h4>From the manual re. include() :</h4>
- <p>"When a file is included, the code it contains inherits
- <br/>the variable scope of the line on which the include occurs.
- <br/><br/>Any <b>variables</b> available at that line in the calling file will be available <br/>
- within the called file, from that point forward.
- <br/><br/>However, all <b>functions and classes</b> defined in the included file have the global scope."*** <br><br>[*** but only after the line on which they're included]</p>
- <p>Try moving the php inculde around to see how it affects the scope of $a and hello()</p>
- </blockquote>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement