Jump to content


Photo

Code stops after require


  • Please log in to reply
6 replies to this topic

#1 Floyd10

Floyd10
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 April 2006 - 08:26 AM

I'm trying to create a login code. I'm using the PEAR to connect to mysql. So, I link to the single database connection page on all many other pages with the require function. However, for some reason I can't figure out, after the require function no code processes. I do not recieve an error message. The code before the require function processes. I haven't a clue what's wrong?

Here is the connection page (db_connect.php):
<?php


//require the PEAR::DB classes.

require_once 'DB.php';

$db_engine = 'mysql';
$db_user = 'root';
$db_pass = 'xxxxxx';
$db_host = 'localhost'; 
$db_name = 'my_db';

 
$datasource = $db_engine.'://'.
              $db_user.':'.
              $db_pass.'@'.
               $db_host.'/'.
                $db_name;


$db_object = DB::connect($datasource, TRUE);

/* assign database object in $db_object, 

if the connection fails $db_object will contain

the error message. */

// If $db_object contains an error:

// error and exit.

if(DB::isError($db_object)) {
    die($db_object->getMessage());
}

$db_object->setFetchMode(DB_FETCHMODE_ASSOC);


include('check_login.php');


?>

Here is the first portion of one of my other pages:
<?php
echo first;
require('db_connect.php');

echo second;
In this the word 'first' would be executed, but the word 'second' would not. No error message. This happens on all my pages that have the require function. Any advice would be appreciated. Thank you.

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 19 April 2006 - 10:59 AM

Maybe you've got a problem with the db_connect.php file. Can you post it here?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Floyd10

Floyd10
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 April 2006 - 06:18 PM

[!--quoteo(post=366364:date=Apr 19 2006, 06:59 AM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ Apr 19 2006, 06:59 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Maybe you've got a problem with the db_connect.php file. Can you post it here?

Orio.
[/quote]

The first code was the db_connect.php file.

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 19 April 2006 - 07:37 PM

I would suggest that you run the db_connect.php file on it's own and see if you get any errors. Usually failure after an include or a require is a direct result with the file you're trying to include/require.... which is what Orio was trying to say.

Info: PHP Manual


#5 Floyd10

Floyd10
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 April 2006 - 09:24 PM

I figured out what the problem was: My php.ini file is not being read. Thus, the session settings are wrong. Unfortunately, I don't know how to fix this.

I used phpinfo() to see where the php.ini file was and c:/winnt came up as the php.ini directory, but that isn't even a directory on my computer. So, I created the directory and copied my php.ini file into it to see if that would work as a temporary fix, but it didn't. How do I get the server to use my php.ini file instead of whatever it is using?

#6 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 20 April 2006 - 01:47 AM

[!--quoteo(post=366605:date=Apr 19 2006, 04:24 PM:name=Floyd10)--][div class=\'quotetop\']QUOTE(Floyd10 @ Apr 19 2006, 04:24 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I figured out what the problem was: My php.ini file is not being read. Thus, the session settings are wrong. Unfortunately, I don't know how to fix this.

I used phpinfo() to see where the php.ini file was and c:/winnt came up as the php.ini directory, but that isn't even a directory on my computer. So, I created the directory and copied my php.ini file into it to see if that would work as a temporary fix, but it didn't. How do I get the server to use my php.ini file instead of whatever it is using?
[/quote]

im pretty sure c:/winnt is like c:/windows on xp machines. It's most likely hidden from view.

#7 Floyd10

Floyd10
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 April 2006 - 03:49 AM

Thanks, I fixed it by adding the php.ini file to the windows folder.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users