Jump to content


Photo

include_once doing nothing


  • Please log in to reply
4 replies to this topic

#1 Janna

Janna
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 October 2006 - 02:54 AM

Hi,

Here is my problem.
I have a file called golobals.php that has the following function in it.
<php?
//connecting to database
function dbconnect($host, $user, $passwd, $database)
{
	 $link = mysql_connect($host, $user, $passwd);
	   if ( !$link ) die("Couldn't connect to MYSQL: ".mysql_error());
	   mysql_select_db($database, $link) or die("Couldn't open database".mysql_error());
	   return $link;
}
?>

In my script I have the following lines
<?php 
session_start();
include_once("globals.php");
...
$DB = dbconnect($db_hostname, $db_username, $db_password, $db_database);
...

The error I get is that the function dbconnect is undefined. I have tried to use require function instead but it gives the same result (no errors about failed require).
Do I have a problem with the path? (I use 1and1 if it matters)

Janna

#2 bqallover

bqallover
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • LocationLeeds, UK

Posted 27 October 2006 - 03:01 AM

If that's a cut-and-paste of your code, can you spot the fatal typo on the very first line?  ;)

#3 Janna

Janna
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 October 2006 - 03:07 AM

Thanks!  :-[

I am sure you can tell that I am a noob to php. - I was actually wondering why the code didn't show up in color in the forum.

I am surprised though that php doesn't give any warning about including crap/

Thanks again,

Janna

#4 bqallover

bqallover
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • LocationLeeds, UK

Posted 27 October 2006 - 03:19 AM

We've all made that miistake - no worries!

It is strange that PHP didn't cough out more errors.  I just quickly included your file in a command-line script and it just output the file contents. 

Oh well, who knows?  :)

#5 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 27 October 2006 - 03:23 AM

If there's no '<?', then it's none of php's business.  It'll just treat it as html and not process it at all.  So that's why there's no errors.

And yes, we've all made that mistake :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users