xProteuSx Posted December 4, 2007 Share Posted December 4, 2007 Here is the problem: If I use this, the script works: <?php some miscellaneous code; ?><?php include="whatever.php";?><?php some miscellaneous code; ?> However, if I do this it does not: <?php some miscellaneous code; include="whatever.php"; some miscellaneous code; ?> What the haps?? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2007 Share Posted December 4, 2007 your include syntax is wrong include="whatever.php"; should be include "whatever.php"; Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 4, 2007 Author Share Posted December 4, 2007 Sorry. I meant include "whatever.php"; This doesn't work, even without the equal sign. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2007 Share Posted December 4, 2007 post your code we cannot tell otherwise, there could be many reasons Quote Link to comment Share on other sites More sharing options...
dg Posted December 4, 2007 Share Posted December 4, 2007 try this ...... include_once("file_name"); Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 4, 2007 Author Share Posted December 4, 2007 This is the version with the include function commented out. It works perfectly. { echo '<center>'; echo '<table width=\"400\">'; echo '<tr>'; echo '<tr height=3>'; echo '<td></td>'; echo '<tr>'; echo '<tr border=1>'; echo '<td bgcolor=#d0d0d0 width=120><font size=+2><center><b>Members List</b></center></font></td>'; echo '<tr>'; echo '<tr height=8>'; echo '<td></td>'; echo '<tr>'; echo '</table>'; echo '</center>'; //include "include/db.php"; mysql_connect('server','user','pass') or die ('Unable to connect to MySQL Server'); mysql_select_db('database') or die ('Unable to select DB'); $query = 'SELECT users_handle FROM users'; $result = mysql_query($query) or die ('Error in query: ' . mysql_error()); etc. } This is the version with the include function called up. It does not work. { echo '<center>'; echo '<table width=\"400\">'; echo '<tr>'; echo '<tr height=3>'; echo '<td></td>'; echo '<tr>'; echo '<tr border=1>'; echo '<td bgcolor=#d0d0d0 width=120><font size=+2><center><b>Members List</b></center></font></td>'; echo '<tr>'; echo '<tr height=8>'; echo '<td></td>'; echo '<tr>'; echo '</table>'; echo '</center>'; include "include/db.php"; $query = 'SELECT users_handle FROM users'; $result = mysql_query($query) or die ('Error in query: ' . mysql_error()); etc. } Contents of db.php: ------------------------------------------------------------------------------------------------------ $server = "server";// Your MySQL Server (usually "localhost") $db_user = "username";// Your MySQL Username $db_pass = "password";// Your MySQL Password $database = "database";// Database Name mysql_connect('$server','$db_user','$db_pass') or die ('Unable to connect to MySQL Server'); mysql_select_db('$database') or die ('Unable to select DB'); ------------------------------------------------------------------------------------------------------ That's all ... Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 4, 2007 Author Share Posted December 4, 2007 include_once("file_name"); no worky!! Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 4, 2007 Share Posted December 4, 2007 You have over 80 posts... please use BBCode code tags with a <?php at the top of each code snippet. That way we get color coded code that is easier to troubleshoot. Please replace your db.php with this. run the script that includes db.php. Does "I died in db.php!" appear onscreen? <?php die("I died in db.php!"); $server = "server";// Your MySQL Server (usually "localhost") $db_user = "username";// Your MySQL Username $db_pass = "password";// Your MySQL Password $database = "database";// Database Name mysql_connect('$server','$db_user','$db_pass') or die ('Unable to connect to MySQL Server'); mysql_select_db('$database') or die ('Unable to select DB'); ?> PhREEEk Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2007 Share Posted December 4, 2007 lol PhREEEk you really love the die statement Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 4, 2007 Share Posted December 4, 2007 I love whatever gets the job done... PhREEEk Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2007 Share Posted December 4, 2007 The include file does not contain <?php and ?> tags, so the contents of it is not parsed. BTW: The pseudo code examples in the first post are not the same as what the actual two code examples are doing. No one would have been able to help you based on the information in the first post. The only way to get specific with what your code is or is not doing is if you post your actual code. Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 4, 2007 Author Share Posted December 4, 2007 Got it figured out ... Just had to change this: mysql_connect('$server','$db_user','$db_pass') or die ('Unable to connect to MySQL Server'); mysql_select_db('$database') or die ('Unable to select DB'); To this: mysql_connect($server,$db_user,$db_pass) or die ('Unable to connect to MySQL Server'); mysql_select_db($database) or die ('Unable to select DB'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.