Help please with a piece of code using php in Drupal

Status
Not open for further replies.

IainQ

Member
Hi everyone,

I was wondering if someone could help me with me with a slight problem using php and Drupal.
I have set up a localhost account on a memory stick using EasyPhp and with this installed Drupal. I set up a database, which works fine, but when trying to go through the standard install process a small piece of code seems to block me from going any further.

Big white page with "Fatal Error: something to do with failing after 30 seconds and then it refers to the page which is database.mysql.inc and says the error is on Line 108.

The reason for my vagueness is because it is set up on my PC, which is off now, and Im now on my mac, so i can post more details tomorrow if neccesary.
But! I have the file to hand and below is the small piece of code which seems to be causing the prblem. If anyone knows anything about this kind of issue please help me. I have tried adding code to lengthen the timeout period, this didnt work. And i have searched forums with no success.

I can provide any more details or files if need be.
Many thanks. Iain.


Code starting from Line 108 (which browser is picking up as error causing):

$result = mysql_query($query, $active_db);


if (variable_get('dev_query', 0)) {
$query = $bt[2]['function'] ."\n". $query;
list($usec, $sec) = explode(' ', microtime());
$stop = (float)$usec + (float)$sec;
$diff = $stop - $timer;
$queries[] = array($query, $diff);
}

if ($debug) {
print '<p>query: '. $query .'<br />error:'. mysql_error($active_db) .'</p>';
}

if (!mysql_errno($active_db)) {
return $result;
}
else {
// Indicate to drupal_error_handler that this is a database error.
${DB_ERROR} = TRUE;
trigger_error(check_plain(mysql_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
return FALSE;
}
}

/**
* Fetch one result row from the previous query as an object.
*
* @param $result
* A database query result resource, as returned from db_query().
* @return
* An object representing the next row of the result, or FALSE. The attributes
* of this object are the table fields selected by the query.
*/
function db_fetch_object($result) {
if ($result) {
return mysql_fetch_object($result);
}
}

/**
* Fetch one result row from the previous query as an array.
*
* @param $result
* A database query result resource, as returned from db_query().
* @return
* An associative array representing the next row of the result, or FALSE.
* The keys of this object are the names of the table fields selected by the
* query, and the values are the field values for this result row.
*/
function db_fetch_array($result) {
if ($result) {
return mysql_fetch_array($result, MYSQL_ASSOC);
}
}

/**
* Return an individual result field from the previous query.
*
* Only use this function if exactly one field is being selected; otherwise,
* use db_fetch_object() or db_fetch_array().
*
* @param $result
* A database query result resource, as returned from db_query().
* @return
* The resulting field or FALSE.
*/
function db_result($result) {
if ($result && mysql_num_rows($result) > 0) {
// The mysql_fetch_row function has an optional second parameter $row
// but that can't be used for compatibility with Oracle, DB2, etc.
$array = mysql_fetch_row($result);
return $array[0];
}
return FALSE;
}
 
Fatal Error: Maximum execution time of 30 seconds exceeded in... directory_where_it_is_stored/database.mysql.inc
 
I must add that I have read many forums which suggest upping the ammount of time which it takes to process such execution but this did not work and I also read that it can lead to other problems when doing this - I would much rather work out what the coding issue is and go from there.
 
Sorry for all of this - I have actually fixed the issue - I added a piece of code to the beginning of one of the configuration files to set the waiting time to process strings to unlimited and it works fine now :) So I am extremely happy and exploring the joys of drupal. Thanks all.
 
Glad you got it sorted Iain, only used Drupal once or twice myself so knew I wouldn't be able to assist!
Will close the thread for you. Thanks, Greg
 
Status
Not open for further replies.
Back
Top