Connecting Tech Pros Worldwide Help | Site Map

require_once('DB.php') failure

danza4ever@yahoo.com
Guest
 
Posts: n/a
#1: Jul 17 '05
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

chotiwallah
Guest
 
Posts: n/a
#2: Jul 17 '05

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

danza4ever@yahoo.com
Guest
 
Posts: n/a
#3: Jul 17 '05

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,'^');
?>

danza4ever@yahoo.com
Guest
 
Posts: n/a
#4: Jul 17 '05

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.

Closed Thread


Similar PHP bytes