2009-07-13 08:59:35 UTC
I had the same problem I tried everything. The file /lib/database/mysql.php is not resolving for the browsers. The file opened in single line instead of in coded format from my host in firefox. I opened the file in IE and copied and pasted in mysql.php. the it showed up in several lines and without errors. Now the site is working. I give the code in several lines with proper indentation.
file lib/database/mysql.php
<?php
/**
* Lib - mysql database functions
*
* @package api
* @subpackage database
* @link
http://props.sourceforge.net/
* PROPS - Open Source News Publishing Platform
* @copyright Copyright (c) 2001 The Herald-Mail Co.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 'LICENSE' file included with this software for more details.
*
* @license
http://www.gnu.org/licenses/gpl.txt GNU GENERAL PUBLIC LICENSE
* @version $Id: mysql.php,v 1.25 2008/01/07 16:17:07 roufneck Exp $
* @todo somehow including this file outputs an empty line, fix it???
*/
$GLOBALS['PROPS_DB_QUERIES'] = 0;
/**
* Opens or reuses a connection to a database server.
*
* @return resource SQL link identifier on success, or FALSE on failure.
*/
function sql_connect()
{
if (isset($GLOBALS['PROPS_DB_CONNECTION_ID']) && is_resource($GLOBALS['PROPS_DB_CONNECTION_ID'])) {
return $GLOBALS['PROPS_DB_CONNECTION_ID'];
}
@ini_set('track_errors', TRUE);
$php_errormsg = '';
$connection = @mysql_connect(props_getkey('config.db.host'), props_getkey('config.db.user'), props_getkey('config.db.password'));
@ini_restore('track_errors');
if (!$connection) {
$GLOBALS['PROPS_ERRORDESC'] = props_gettext("The database is currently offline. Please try again later.");
if (@mysql_error() != '') {
trigger_error('SQL error (' . mysql_errno() . '): '.mysql_error(), E_USER_ERROR);
} else {
trigger_error($php_errormsg, E_USER_ERROR);
}
}
if (props_getkey('config.db.name')) {
if (!@mysql_select_db(props_getkey('config.db.name'), $connection)) {
$GLOBALS['PROPS_ERRORDESC'] = props_gettext("Database error. Please try again later.");
if (@mysql_error() != '') {
trigger_error('SQL error: Could not select the database ' . props_getkey('config.db.name'), E_USER_ERROR);
} else {
trigger_error($php_errormsg, E_USER_ERROR);
}
}
}
$GLOBALS['PROPS_DB_CONNECTION_ID'] = $connection;
if (props_getkey('config.UTF8-detection') == TRUE) {
// Make sure any results we retrieve or commands we send use the same
// charset and collation as the database.
$db_charset = mysql_query("SHOW VARIABLES LIKE 'character_set_database'");
$charset_row = mysql_fetch_assoc($db_charset);
mysql_query("SET NAMES '" . $charset_row['Value'] . "'");
props_setkey('db.charset', $charset_row['Value']);
unset($db_charset, $charset_row);
}
if (props_getkey('config.debug_mode')) {
$result = mysql_query("SHOW VARIABLES LIKE 'c%'");
while ($row = sql_fetch_object($result)) {
props_debug('SQL: '.$row->Variable_name . ' :: ' . $row->Value, E_DEBUG, __FILE__, __LINE__);
}
}
return $connection;
}
/**
* Sends a query to the currently active database on the server.
*
* @param string $query SQL query. The query string should not end with a semicolon.
* @return resource result resource|TRUE|FALSE
*/
function sql_query($query)
{
$GLOBALS['PROPS_DB_QUERIES']++;
props_debug('SQL: '.$query, E_DEBUG, __FILE__, __LINE__);
$connection = sql_connect();
$result = mysql_query($query, $connection);
if ($result === FALSE) {
$GLOBALS['PROPS_ERRORDESC'] = props_gettext("Database error. Please try again later.");
trigger_error('SQL error (' . mysql_errno() . '): '.mysql_error().' - : '.$query, E_USER_ERROR);
}
return $result;
}
/**
* Sends a query to the currently active database on the server and retrieves
* the ID generated for an AUTO_INCREMENT column by the query.
*
* @param string $query SQL query
* @return resource result resource|TRUE|FALSE
*/
function sql_identity_insert($query)
{
$GLOBALS['PROPS_DB_QUERIES']++;
props_debug('SQL: '.$query, E_DEBUG, __FILE__, __LINE__);
$connection = sql_connect();
$result = sql_query($query);
// No error - get the generated ID
$id = mysql_insert_id($connection);
if ($result === FALSE) {
$GLOBALS['PROPS_ERRORDESC'] = props_gettext("Database error. Please try again later.");
trigger_error('SQL error (' . mysql_errno() . '): '.mysql_error().' - : '.$query, E_USER_ERROR);
}
return $id;
}
/**
* Returns an object with properties that correspond to the fetched row and moves
* the internal data pointer ahead.
*
* @param resource $result The result resource that is being evaluated. This
* result comes from a call to sql_query().
* @return object Returns an object with properties that correspond to the fetched
* row, or FALSE if there are no more rows.
*/
function sql_fetch_object($result)
{
// Return result
return mysql_fetch_object($result);
}
/**
* Returns an array that corresponds to the fetched row and moves the internal
* data pointer ahead.
*
* @param resource $result The result resource that is being evaluated. This
* result comes from a call to sql_query().
* @return array Returns an array that corresponds to the fetched row, or FALSE
* if there are no more rows.
*/
function sql_fetch_array($result)
{
// Return result
return mysql_fetch_array($result);
}
/**
* Returns an associative array that corresponds to the fetched row and moves
* the internal data pointer ahead.
*
* @param resource $result The result resource that is being evaluated. This
* result comes from a call to sql_query().
* @return array Returns an associative array that corresponds to the fetched
* row, or FALSE if there are no more rows.
*/
function sql_fetch_assoc($result)
{
// Return result
return mysql_fetch_assoc($result);
}
/**
* Retrieves the number of rows from a result set. This command is only valid
* for SELECT statements. To retrieve the number of rows affected by a INSERT,
* UPDATE, or DELETE query, use sql_affected_rows().
*
* @param resource $result The result resource that is being evaluated. This
* result comes from a call to sql_query().
* @return int The number of rows in a result set on success, or FALSE on failure.
*/
function sql_num_rows($result)
{
// Return result
return mysql_num_rows($result);
}
/**
* Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE
* query.
*
* @return int the number of affected rows on success, and -1 if the last query failed.
*/
function sql_affected_rows()
{
// Return result
return mysql_affected_rows();
}
/**
* Free all memory associated with the result identifier result.
*
* @param resource $result The result resource that is being evaluated. This
* result comes from a call to sql_query().
* @return bool Returns TRUE on success, FALSE on failure.
*/
function sql_free_result($result)
{
return mysql_free_result($result);
}
/**
* Retrieves the server version.
*
* @return mixed Returns the server version on success, or FALSE on failure.
*/
function sql_server_version()
{
return mysql_get_server_info();
}
/**
* Recursive escapes special characters in the string or array so that it is
* safe to place it in a sql_query().
*
* This function must always (with few exceptions) be used to make data safe
* before sending a SQL query.
*
* @param mixed $string The string or array that is to be escaped.
* @return string Returns the escaped string, or FALSE on error.
*/
function sql_escape_string($string)
{
if (is_array($string)) {
$string = array_map('sql_escape_string', $string);
} else {
$connection = sql_connect();
$string = mysql_real_escape_string($string, $connection);
}
return $string;
}
?>