Restored last years program WORKED then, but not now??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Restored last years program WORKED then, but not now??

Post by camarosource »

I restored an version of my program from November, 2007 which SHOULD be the same as current. I restored it and have these strange unexplainable errors that are now showing up that didn't back then. I am assuming perhaps back then it was a different php version and now perhaps php on my server may have been upgraded? I don't have any other explaination as to why it would work back in 2007 and not now..

Here are the errors I am getting...
NOTE: Due to this website being VERY well known, to resist hacking I've "[HIDDEN]" the paths to the files.
Notice: Use of undefined constant DB_HOSTNAME - assumed 'DB_HOSTNAME' in /home/[HIDDEN]/[HIDDEN]/[HIDDEN]/[HIDDEN]/cotm.php on line 4

Notice: Use of undefined constant DB_USERNAME - assumed 'DB_USERNAME' in /home/[HIDDEN]/[HIDDEN]/[HIDDEN]/[HIDDEN]/cotm.php on line 4

Notice: Use of undefined constant DB_PASSWORD - assumed 'DB_PASSWORD' in /home/[HIDDEN]/[HIDDEN]/[HIDDEN]/[HIDDEN]/cotm.php on line 4

Warning: mysql_connect(): Unknown MySQL Server Host 'DB_HOSTNAME' (1) in /home/[HIDDEN]/[HIDDEN]/[HIDDEN]/[HIDDEN]/cotm.php on line 4
connect failed: Unknown MySQL Server Host 'DB_HOSTNAME' (1)

(cotm.php)

Code: Select all

 
<?php
require('config.php');
 
mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD) or die('connect failed: ' . mysql_error());
$sql = 'SELECT full_name, DATE_FORMAT(camaro_of_the_month,\'%M, %Y\') AS cotm_month_year, car_year, model, type, city, state_or_province, country, ride_id FROM '
 . DB_FRIDES_RIDE . ',' . DB_FRIDES_OWNER
 . ' WHERE ' . DB_FRIDES_RIDE . '.user_id=' . DB_FRIDES_OWNER . '.user_id'
 . ' ORDER BY camaro_of_the_month DESC LIMIT 1';
$result = mysql_query($sql) or die('query failed: ' . mysql_error());
$row = mysql_fetch_assoc($result);
 
include('cotm.htm');
?>
 
(config.php)
NOTE: Due to this website being VERY well known, to resist hacking I've "[HIDDEN]" the logging in username/password of course.

Code: Select all

 
<?php
if(!defined('INCLUDE_CONFIG')) {
define('INCLUDE_CONFIG', true);
 
/* database connection */
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', '[HIDDEN]');
define('DB_PASSWORD', '[HIDDEN]');
 
/* database names */
define('DB_FRIDES', '[HIDDEN]_frides');
define('DB_PHPBB', '[HIDDEN]_phpBB2');
?>
 
I contacted my host 2 days ago to look at my coding and see why it's not working anymore, but still no response and I continue to get NONSTOP emails from all my visitors about the site being down.. HELP! Thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Restored last years program WORKED then, but not now??

Post by John Cartwright »

Code: Select all

 
<?php
if(!defined('INCLUDE_CONFIG')) {
define('INCLUDE_CONFIG', true);
 
/* database connection */
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', '[HIDDEN]');
define('DB_PASSWORD', '[HIDDEN]');
 
/* database names */
define('DB_FRIDES', '[HIDDEN]_frides');
define('DB_PHPBB', '[HIDDEN]_phpBB2');
?>
 
Where is the closing bracket in your config.php? I have to assume that there is more code that you didn't post, which makes me wonder if those defines are ever getting run.

Code: Select all

var_dump(defined('INCLUDE_CONFIG')); //or var_dump(constant('INCLUDE_CONFIG'));
If this outputs true then those defines will not be run.
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Re: Restored last years program WORKED then, but not now??

Post by camarosource »

FULL CODE

Code: Select all

 
<?php
if(!defined('INCLUDE_CONFIG')) {
define('INCLUDE_CONFIG', true);
 
/* frides homepage (fully qualified url) */
define('FRIDES_HOMEPAGE', 'http://www.[HIDDEN]/php/frides/rides_list.php');
 
/* administrator email address */
define('ADMIN_EMAIL', '[HIDDEN]');
 
/* database connection */
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', '[HIDDEN]');
define('DB_PASSWORD', '[HIDDEN]');
 
/* database names */
define('DB_FRIDES', '[HIDDEN]_frides');
define('DB_PHPBB', '[HIDDEN]_phpBB2');
 
/* table names */
define('DB_PHPBB_USERS', DB_PHPBB . '.phpbb_users');
define('DB_FRIDES_RIDE', DB_FRIDES . '.ride');
define('DB_FRIDES_OWNER', DB_FRIDES . '.owner');
define('DB_FRIDES_FEEDBACK', DB_FRIDES . '.feedback');
 
/* number of checkboxes for 'ride' details */
define('RIDE_CHECKBOX_COUNT', 45);
 
/* session */
define('SESSION_NAME', '[HIDDEN]_frides_sid');
 
/* pathnames (end with /) */
define('PATH_TO_RIDE_PHOTOS', './photos/');
define('PATH_TO_PHPBB', '/forums/');
 
/* templates */
define('RIDE_SUBMIT_TPL', 'frides_submit.htm');
define('LOGIN_TPL', 'frides_login.htm');
define('RIDES_LIST_TPL', 'frides_list.htm');
define('RIDE_DETAILS_TPL', 'frides_details.htm');
define('PROFILE_SUBMIT_TPL', 'frides_submit_owner_info.htm');
define('PHOTO_SUBMIT_TPL', 'frides_add_pics.htm');
define('PHOTO_UPLOAD_TPL', 'frides_add_pics_upld.htm');
define('UPLOAD_PROGRESS_TPL', 'photo_upload_progress.htm');
define('EMAIL_SUBMIT_USER_TPL', 'email_submit_user.txt');
define('EMAIL_SUBMIT_ADMIN_TPL', 'email_submit_admin.txt');
define('RATE_TPL', 'rate.htm');
define('COMMENT_TPL', 'comments.htm');
 
/* script filenames */
define('PROFILE_SUBMIT_PHP', 'profile_submit.php');
define('RIDE_SUBMIT_PHP', 'ride_submit.php');
define('PHOTO_PANEL_PHP', 'photo_submit.php');
define('LOGIN_PHP', 'login.php');
define('RIDES_LIST_PHP', 'rides_list.php');
define('RIDE_DETAILS_PHP', 'ride_details.php');
define('COMMENT_PHP', 'comment.php');
define('RATE_PHP', 'rate.php');
 
/* login messages */
define('LOGIN_MSG_DEFAULT', '');
define('LOGIN_MSG_MISSING', '<b><font color="#FF0000">Please enter BOTH a username AND a password.</font></b>');
define('LOGIN_MSG_NOMATCH', '<b><font color="#FF0000">The username and password entered did not match.</font></b>');
 
/* ride_submit messages */
define('RIDE_SUBMIT_MSG_DEFAULT', '<b><font size="4" face="Times New Roman">&nbsp;Note: "</font><font color="#FF0000" face="Times New Roman" size="4">*</font><font size="4" face="Times New Roman">" are required Fields.</font></b>');
define('RIDE_SUBMIT_MSG_MISSING_YEAR', '<b><font color="#FF0000">Please enter the "year".</font><br>');
define('RIDE_SUBMIT_MSG_MISSING_MODEL', '<b><font color="#FF0000">Please enter the "model".</font><br>');
define('RIDE_SUBMIT_MSG_MISSING_TYPE', '<b><font color="#FF0000">Please enter the "type".</font><br>');
 
/* profile_submit messages */
define('PROFILE_SUBMIT_MSG_DEFAULT', '<b><font size="4" face="Times New Roman">&nbsp;Note: "</font><font color="#FF0000" face="Times New Roman" size="4">*</font><font size="4" face="Times New Roman">" are required Fields.</font></b>');
define('PROFILE_SUBMIT_MSG_MISSING_FULL_NAME', '<font color="#FF0000"><b>Please enter your full name.</font><br>');
define('PROFILE_SUBMIT_MSG_MISSING_CITY', '<font color="#FF0000"><b>Please enter your city.</font><br>');
define('PROFILE_SUBMIT_MSG_MISSING_STATE', '<font color="#FF0000"><b>Please enter your state/province.</font><br>');
define('PROFILE_SUBMIT_MSG_MISSING_COUNTRY', '<font color="#FF0000"><b>Please enter your country.</font><br>');
define('PROFILE_SUBMIT_MSG_MISSING_WHERE_HEARD', '<font color="#FF0000"><b>Please tell us where you heard about [HIDDEN].</font><br>');
 
/* number of days a new ride is considered "new" */
define('NUM_DAYS_NEW', 7);
 
/* number of days a ride is cotm (0=forever) */
define('NUM_DAYS_COTM', 0);
 
/* images */
define('IMG_BULLET', '<img src="bullet.gif" width="6" height="6" border="0">');
define('IMG_ICON_NEW', '<img src="new.gif" width="30" height="14" border="0">');
define('IMG_ICON_COTM', '<img src="cotm_icon.gif" width="20" height="36" border="0">');
define('IMG_ICON_URL', '<img src="url_icon.gif" width="14" height="17" border="0">');
define('IMG_ICON_ICQ', '<img src="icq_icon.gif" width="15" height="17" border="0">');
define('IMG_ICON_MSN', '<img src="msn_icon.gif" width="16" height="16" border="0">');
define('IMG_ICON_AIM', '<img src="aim_icon.gif" width="13" height="16" border="0">');
define('IMG_ICON_YIM', '<img src="yim_icon.gif" width="16" height="16" border="0">');
define('IMG_ICON_TRASH', '<img src="icon_trash.gif" width="13" height="16" border="0">');
define('IMG_CHECKMARK', '<img src="check.gif" width="20" height="20" border="0">');
define('IMG_BUTTON_EMAIL', '<img src="icon_email.gif" width="59" height="18" border=0">');
define('IMG_BUTTON_ICQ', '<img src="icon_icq.gif" width="59" height="18" border="0">');
define('IMG_BUTTON_AIM', '<img src="icon_aim.gif" width="59" height="18" border="0">');
define('IMG_BUTTON_YIM', '<img src="icon_yim.gif" width="59" height="18" border="0">');
define('IMG_BUTTON_MSN', '<img src="icon_msnm.gif" width="59" height="18" border="0">');
define('IMG_BUTTON_PM', '<img src="icon_pm.gif" width="59" height="18" border="0">');
define('IMG_NO_EMAIL', '<img src="icon_no_email.gif" width="59" height="18" border="0">');
define('IMG_NO_ICQ', '<img src="icon_no_icq.gif" width="59" height="18" border="0">');
define('IMG_NO_AIM', '<img src="icon_no_aim.gif" width="59" height="18" border="0">');
define('IMG_NO_YIM', '<img src="icon_no_yim.gif" width="59" height="18" border="0">');
define('IMG_NO_MSN', '<img src="icon_no_msn.gif" width="59" height="18" border="0">');
define('IMG_NO_THUMBNAIL', '<img src="no_image.gif" width="104" height="92" border="0">');
define('IMG_COMMENT_STAR', '<img border="0" src="star.gif" width="16" height="16">');
define('IMG_COMMENT_HALFSTAR', '<img border="0" src="half_star.gif" width="8" height="16">');
 
/* email subject for email link */
define('EMAIL_SUBJECT', 'About your ride');
 
/* aim message for aim link */
define('AIM_MESSAGE', 'Hello Are you there?');
 
/* thumbnail width and height (used for both creating and displaying) */
define('THUMBNAIL_W', 100);
define('THUMBNAIL_H', 64);
 
/* cotm photo width and height */
define('COTM_IMAGE_W', 320);
define('COTM_IMAGE_H', 240);
define('COTM_JPG_FILE', PATH_TO_RIDE_PHOTOS . 'cotm.jpg');
 
/* how to handle thumbnail creation when aspect ratios differ
    (0 - stretch, 1 - clip, 2 - fit) */
define('THUMBNAIL_RESIZE_METHOD', 2);
 
/* max. allowable size of photo upload in bytes */
define('PHOTO_MAXSIZE', 102400);
 
/* largest possible photo_id (ie. max. number of photos user allowed to store on website */
define('MAX_PHOTO_NUM', 3);
 
/* JPEG quality 0 (worst quality, smaller file) to 100 (best quality, biggest file)*/
define('JPEG_QUALITY', 80);
 
/* auto login cookie names */
define('AUTOLOGIN_USERNAME', '[HIDDEN]');
define('AUTOLOGIN_PASSWORD', '[HIDDEN]');
 
/* email settings */
//define('SMTP_HOST', 'shawmail');
define('EMAIL_FROM', '[HIDDEN]');
 
/* rating analysis bars' dimensions */
define('ANAL_BAR_W', 12); //12
define('ANAL_BAR_H', 101); //101
 
/* max. number of 'rides' per user */
define('MAX_NUM_RIDES', 5);
}
?>
 
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Restored last years program WORKED then, but not now??

Post by John Cartwright »

Try running the piece of code I posted and post the results
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Re: Restored last years program WORKED then, but not now??

Post by camarosource »

bool(false)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Restored last years program WORKED then, but not now??

Post by John Cartwright »

Weird. I really don't know what could be the cause. Sorry.
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Re: Restored last years program WORKED then, but not now??

Post by camarosource »

Seems ALL my "define('VARIABLE', 'STORED INFO');" is NOT saving??

ie. define('DB_HOSTNAME', 'localhost');

Once goes to cotm.php the variables are LOST..

"Define" should automatically SAVE it as a constant variable should it not?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Restored last years program WORKED then, but not now??

Post by Chris Corbyn »

camarosource wrote:"Define" should automatically SAVE it as a constant variable should it not?
Yes it should. It seems more likely that the configuration is not being require()'d into the rest of the system. Try sticking a:

Code: Select all

<?php die('here'); ?>
Right at the top of that file with all the define()'s in it. See if your application then dies with the word "here". If it doesn't then that file is not ever being included.
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

Re: Restored last years program WORKED then, but not now??

Post by camarosource »

GOT IT! STRANGE THO.. As I mentioned before the script has not even been changed or even touched since 2007.. Basically worked less than a year ago but not now..

I looked at the script that calls the cotm.php program in my main page of the site

Code: Select all

 
<?php include('cotm.php') ?>
 
and realized it was pointing to ANOTHER cotm.php in my MAIN folder and so all these experimenting with the cotm.php in /php/frides/ was not the actual one it was pointing to..

I changed it to the correct ABSOLUTE PATH and it works!

DOH.. I feel so stupid. :) Thanks SO very much for everyones time and help.
Post Reply