aarushi2001 Posted March 29, 2006 Share Posted March 29, 2006 Hi,I am using PHP 4.3.11. I have recently started coding in PHP and I need help.I am trying to connect to the DB, I have created files: config.inc and opendb.inc, when I call these files using include() function, I get a blank page.But if I dont use the include() and hard-code my php files, I am able to access the database.Can anyone help me?Thanks Quote Link to comment Share on other sites More sharing options...
ober Posted March 29, 2006 Share Posted March 29, 2006 Can you show us your code? Specifically how you use the includes? And is the code that you hardcode with the same code as in the files you include? Quote Link to comment Share on other sites More sharing options...
aarushi2001 Posted March 29, 2006 Author Share Posted March 29, 2006 [!--quoteo(post=359693:date=Mar 29 2006, 11:23 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 29 2006, 11:23 AM) [snapback]359693[/snapback][/div][div class=\'quotemain\'][!--quotec--]Can you show us your code? Specifically how you use the includes? And is the code that you hardcode with the same code as in the files you include?[/quote]Hi,Thanks for such a quick response, Code which include 'include()'<?php include 'config.php'; include 'opendb.php'; $query = "SELECT firstname FROM customers"; $result = mysql_query($query); while ($line = mysql_fetch_array($result)) { echo "$line[firstname] <br> $line[lastname]"; }include 'closedb.php';?>Code which doesnot include 'include()'<?php $link = mysql_connect("mysql", "*****", "****"); mysql_select_db("***"); $query = "SELECT firstname, lastname FROM customers"; $result = mysql_query($query); while ($line = mysql_fetch_array($result)) { echo "$line[firstname] <br> $line[lastname]"; }mysql_close($link);?>Thanks 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.