Connecting Tech Pros Worldwide Help | Site Map

require_once('DB.php') failure

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:30 PM
danza4ever@yahoo.com
Guest
 
Posts: n/a
Default require_once('DB.php') failure

I'm using a relatively simple php script to query a mySQL database and
return values formatted to a variable string for interpretation by an
embedded swf. There is one php file that handles the connection to the
db (db_login.php) and one that handles the query (db_getProjects.php).
If I call up the db_getProjects.php file it simply spits back a
"&varibale=value..." blah blah string. The problem is that it works
only half the time...it'll be fine for a while then simply stop working
at all for a while...then start working again. When it isn't working
it is failing to even get past the require_once('DB.php') statement -
anything after that is never reached.

What could I be doing that is causing the require_once('DB.php') to
fail after working flawlessly for stretches?

note: I am making sure to close the connection at the end of each DB
call, so I don't think its due to open DB connections piling up, though
that seems to be the only logical answer.

Thanks,
Jeff


  #2  
Old July 17th, 2005, 01:30 PM
chotiwallah
Guest
 
Posts: n/a
Default Re: require_once('DB.php') failure

that can have any number of reasons. it's impossible to tell from your
description. can't even say wether this is a mysql or a php problem.

what comes to mind is:
1. error_reporting(E_ALL) at the top of your script will print out any
php errors
2. check mysql_error() after any query
3. post error messages here

micha

  #3  
Old July 17th, 2005, 01:30 PM
danza4ever@yahoo.com
Guest
 
Posts: n/a
Default Re: require_once('DB.php') failure

I've added the error_reporting(E_ALL) and it didn't show me anything.
I've had the mysql_error() check after each DB call and they've yet to
return an error. When the script fails I just see nothing. If I drop
in an echo statement before the require_once('DB.php') call it comes
through, but anything after doesn't. Below is the code...

====db_login.php====
<?php
require_once('DB.php');
// SET CONNECTION VARIABLES
$username = 'xxxxxx';
$password = 'xxxxxx';
$hostspec = 'db1.xxxxxx.net';
$database = 'xxxxxxDB';
$phptype = 'mysql';
$dsn =
$phptype.'://'.$username.':'.$password.'@'.$hostspec.'/'.$database;
// CONNECT
$db = DB::connect($dsn);
if(DB::iserror($db)){
die($db->getMessage());
}
?>

====db_getProjects.php====
<?php
require_once('db_login.php');
//QUERY-------------------------------------------
$sql = "SELECT * FROM Projects ORDER BY County";
$q = $db->query($sql);
if(DB::iserror($q)){
die($q->getMessage());
}
$varList = "";
//CONSTRUCT VARIABLE LIST------------------------
while ($row = $q->fetchRow(DB_FETCHMODE_OBJECT)){
if(DB::iserror($row)){
die($row->getMessage());
}
$varList .= $row->County."^".$row->Title."^".$row->Link."^^";
}
$db->disconnect();
echo '&projects='.rtrim($varList,'^');
?>

  #4  
Old July 17th, 2005, 01:30 PM
danza4ever@yahoo.com
Guest
 
Posts: n/a
Default Re: require_once('DB.php') failure

Since this always hung up when loading the PEAR db include, I decided
to ditch PEAR and go with straight mySQL calls and the problem went
away.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.