Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with small PHP code


Peper

Recommended Posts

Posted

I'm trying to disable some contact details in the language/english/contact_us.php page

 

For some reason a number 1 is produced

 

Viewing the source code:

 

1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>........

 

If I put back the old contact_us page the 1 is gone

 

Please help, I could not find the same $sopen or $sclose in code, perhaps something else I must look at?

 

define('HEADING_TITLE', 'Contact Us');
define('NAVBAR_TITLE', 'Contact Us');
define('TEXT_SUCCESS', '<b>Your enquiry has been successfully sent to the Store Owner.</b>');
define('EMAIL_SUBJECT', 'Enquiry from ' . STORE_NAME);
define('ENTRY_NAME', 'Full Name:');
define('ENTRY_EMAIL', 'E-Mail Address:');
define('ENTRY_ENQUIRY', 'Enquiry:');
$c_time = time();
$sopen = strtotime('Today 8am');
$sclose = strtotime('Today 6pm');
if ($c_time > $sopen && $c_time < $sclose) {
   echo define('TEXT_INFORMATION', '<p><strong>How to contact us if we are open</strong></p>
<p>Our contact details</p>
<p>Our address details</p>
');
} else {
   echo define('TEXT_INFORMATION', '<p><strong>Our bussiness Hours if we are closed</strong></p>

<p>Our address details</p>
');
}

Getting the Phoenix off the ground

Posted

take the old contact_us.php file ..... replace the text with the text from your new contact_us.php file ... upload and check it!!!!!

 

ofcourse backup your edited files first in some other directory.

Posted

echo define('TEXT_INFORMATION',...

looks awfully suspicious. A "define" probably returns a 1 (TRUE) if successful, so you end up with "echo 1;"

 

Does TEXT_INFORMATION get used elsewhere? If yes, define it separately, and just echo TEXT_INFORMATION;. If not, just echo the string you want (everything between '). Actually, you probably shouldn't be trying to output to the browser from a language definition file -- it's too early in the process (before even the DOCTYPE has been output).

Posted

@@Peper

 

Viewing the source code:

 

1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>........

 

 

Try removing the 1 from in front of your doctype declaration as shown above....dan

Posted

remove the echo from the language file, there shouldn't be any echo in language files

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted

Thanks for pointing out the echo, now fixed

 

Now I have a server time issue

my time specified seems to be not correct in GMT time -2hrs (Johannesburg)

 

I done echo time();

gives me 1381390311

Getting the Phoenix off the ground

Posted

time() is the raw count of seconds from 1/1/1970 (start of the Unix Epoch). If your formatted time is incorrect, you can tell PHP what timezone you're in. If you have the ability to use a php.ini file, you can add one with a line

date.timezone = 'Africa/Johannesburg'

If not, you could add a line

ini_set('date.timezone', 'Africa/Johannesburg');

at some appropriate point near the top of your application_top.php files.

Posted

Thanks - solved

I tried adding lines as above, no change

 

PHP info shows server date time correct Server Date: 10/10/2013 17:19:43

 

So with bit of direction I added this to contact_us.php (or application_top.php) and seems to be working perfectly

 

date_default_timezone_set('Africa/Johannesburg');

Getting the Phoenix off the ground

Posted

Yes, that should be an equivalent way to do it.

 

Don't forget that you have two application_top files: one for admin and one for the storefront.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...