XAMPP problem - php pages just show code, don't build page

  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Firstly I should let you know that I have no idea what I am doing, so will need explanations in very simple terms.
About 7 years ago I created a website, with database, using XAMPP on my PC while I worked on it. I then had the site online for years but hosted by someone else, so I uninstalled XAMPP, but now need to make changes to the site and database while it is offline and on my computer.
I have completely forgotten how I got the site and database to run using XAMPP and I know almost nothing about php or SQL, so I need an idiot's guide (I'm sure you are shaking your head in despair by now). I know it can be done because I did it years ago when I worked on this same site.

I have Vista Home Premium and I installed XAMPP 1.8.0, then I put all my site's html and php files (e.g. index.php, library and include folders of files etc., exactly as they were when on my web hosts server) in XAMPP's htdocs folder but if I open the site and go to the index page, all I see in the browser is the php code on that file, it does not seem to extract information from the database and build the page as it did when hosted online. That is, when I go to file:///C:/xampp/htdocs/index.php all it displays in the browser is the php code that is on the index.php file.

I also tried installing XAMPP 1.5.1, as it was probably that one I used first time, but I uninstalled it and put in 1.8.0 instead, however it seems to make no difference which one I use.

I don't know where I should put my database's .sql file (mine is called shopbase.sql) or how to get the site's php files to display the pages properly using data from the database, as it did online. I have currently got that .sql file in C:/xampp/htdocs/mysql/data. I also tried it in C:/xampp/htdocs/mysql - neither place seems to work

I know the site files are fine, as the site displays and behaves as it should when uploaded to my web host and online, I just don't know how to do the same thing with them on my own PC using XMAPP. I don't know if the .sql file is in the wrong place, if I'm overlooking something or if I need to alter code or configurations somewhere to get them to work while in XAMPP's htdocs folder. I probably have to change password and user for the database but I don't think I have even got this working far enough to have even hit that problem yet.

My index.php page begins with...

Code: [ Select ]
<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];

$catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
function valid_pdId($get)
  1. <?php
  2. require_once 'library/config.php';
  3. require_once 'library/category-functions.php';
  4. require_once 'library/product-functions.php';
  5. require_once 'library/cart-functions.php';
  6. $_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];
  7. $catId = (isset($_GET['c']) && $_GET['c'] != '1') ? $_GET['c'] : 0;
  8. function valid_pdId($get)


My config.php file (as seen above in the line with require_once 'library/config.php') begins with...

Code: [ Select ]
<?php
ini_set('display_errors', 'On');
//ob_start("ob_gzhandler");
error_reporting(E_ALL);

// start the session
session_start();

$dbHost = 'localhost';
$dbUser = 'esite';
$dbPass = 'xintox';
$dbName = 'esite';

// setting up the web root and server root for
// this application
$thisFile = str_replace('\\', '/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];

$webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
$srvRoot = str_replace('library/config.php', '', $thisFile);

define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
  1. <?php
  2. ini_set('display_errors', 'On');
  3. //ob_start("ob_gzhandler");
  4. error_reporting(E_ALL);
  5. // start the session
  6. session_start();
  7. $dbHost = 'localhost';
  8. $dbUser = 'esite';
  9. $dbPass = 'xintox';
  10. $dbName = 'esite';
  11. // setting up the web root and server root for
  12. // this application
  13. $thisFile = str_replace('\\', '/', __FILE__);
  14. $docRoot = $_SERVER['DOCUMENT_ROOT'];
  15. $webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
  16. $srvRoot = str_replace('library/config.php', '', $thisFile);
  17. define('WEB_ROOT', $webRoot);
  18. define('SRV_ROOT', $srvRoot);


I also tried a very simple test file which isn't displaying properly...
Code: [ Select ]
<html>
<head>
<title>PHP Test 1</title>
</head>
<body>
<p>This is an html line</p>
<?php echo "this is a php line"; phpinfo();
?>
</body></html>
  1. <html>
  2. <head>
  3. <title>PHP Test 1</title>
  4. </head>
  5. <body>
  6. <p>This is an html line</p>
  7. <?php echo "this is a php line"; phpinfo();
  8. ?>
  9. </body></html>

When I open it in the browser, all it shows is the line 'This is an html line'.
It does not show the line saying 'This is a PHP line'.

Is there something I should have done to make XAMPP display php?

Please bear in mind that I have virtually no knowledge of mysql or php. I didn't originally write the php or create the database, I only added to the database using the ready made files with XAMPP on my PC. The person who helped me then is no longer available to help again. I need the site to display offline exactly as it did when it was online and to have access to the database so that I can add and remove things while it is offline.

Grateful for any help that can be provided.

Regards,
Cerio
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1240
  • Loc: Sydney

Post 3+ Months Ago

o.k here is what you do

install xampp

open control panel and start apache mysql

localhost/phpmyadmin to load the sql if you need the easy way or use cmd to login and well i don't think i am going into detail just use phpmyadmin.

then your going to need to change the database/config.php file to align to the sql so localhost is where your connecting too.

if you did not go through xampp security page when first installed then username is root and no password.

should be able to connect then

but you should really look over a setup guide if a wordpress site, there could be 20 different more settings depending which software and if not custom build.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Thank you so much for your reply, Zealous Professor. I really appreciate it.

I have put my .sql file into the xampp/phpMyAdmin folder.
I suspect that may not be what you meant, as you said "load the sql", not copy it to there but I don't know how to load it.

Now you say, "then you're going to need to change the database/config.php file to align to the sql so localhost is where your connecting too."

I am assuming it is my config.php file, stored in the library folder, which is now in xampp htdocs folder.

To do that, do I just change
Code: [ Select ]
$dbHost = 'localhost';
$dbUser = 'esite';
$dbPass = 'xintox';
$dbName = 'esite';
  1. $dbHost = 'localhost';
  2. $dbUser = 'esite';
  3. $dbPass = 'xintox';
  4. $dbName = 'esite';


to...

Code: [ Select ]
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = 'esite';
  1. $dbHost = 'localhost';
  2. $dbUser = 'root';
  3. $dbPass = '';
  4. $dbName = 'esite';


I fear I may be wrong in that, as, when I open the index.php file (I tried it by opening one of the html files of my site, then opening the home/index.php page via the link to it on the menu on that html page) and all I see in the browser is the php code on the index.php file.

As you can tell, I have no idea what I am doing. Fortunately, I only need this up and running so I can make some alterations to my website, therefore I need it so I can access and change the stuff in the database (which, when the site was online, I could change via the phpMyAdmin page and my webhost's Plesk Panel) and view the website offline, I don't need it for anything more complex or long term than that.

My website isn't a Wordpress site.

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

I don't know if this tells you anything useful but if I go to localhost/index.php (or just localhost) in my browser I get only...
Cannot select database. Unknown database 'esite'

Regards,
Cerio
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1240
  • Loc: Sydney

Post 3+ Months Ago

o.k run through a phpmyadmin reference tutorial and follow;

create database esite

import sql into database


then change your config file to db name 'xintox'

username root
password

unless u changed in xampp security.

should work.

this is web server 101 really
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Thank you

Where can I find the phpmyadmin reference tutorial to learn how to create a database and then import my .sql file?

Found some in a Google search but do you recommend a specific one?

I haven't changed anything in xampp security.

Regards,
Cerio
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1240
  • Loc: Sydney

Post 3+ Months Ago

go to phpmyadmin > click SQL from menu

CREATE DATABASE esite

in Left sidebar click your esite database

once you are in the database back to top menu and click import

Import the SQL file from the dump and click go which should execute the import.

then check your site as long as the database username is root and no password.

If you need the job done quick, i can put someone from my programming team on the job.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Thanks for your help and patience with me.

When importing my .sql file into the newly created database, I got this...

Quote:
Warning: POST Content-Length of 21009913 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
localhost
You probably tried to upload too large file. Please refer to documentation for ways to workaround this limit.


Is their any solution to this? I don't know where the documentation is, to try to find the workaround mentioned, and may be too much of a novice to follow it anyway.


Regards,
Cerio
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1240
  • Loc: Sydney

Post 3+ Months Ago

see
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

see?

Please check my previous post, it may have changed since you first read it. I got so far with your instructions then hit a problem importing the .sql file, due to its size.
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1240
  • Loc: Sydney

Post 3+ Months Ago

when i checked earlier all the reply was "I" then i added "see"

"i see" lol

then you edited your post.

anyway have you checked php.ini on file upload limits?

(No i am not giving instructions this time, Merry-Googling :))

You sure you don't just wana let someone else make the changes for you who is up to date? i am sure i got a programmer who is doing sweet f/a lol somewhere.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

I had already just Googled and found that :-). I changed it from 8M to 25M but it hasn't helped. Also tried changing it to 0 but still same problem as below.

Now getting.

Quote:
No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.


I clicked the See FAQ 1.16. link and what it said meant nothing to me at all; it was this...
Quote:
1.16 I cannot upload big dump files (memory, HTTP or timeout problems).

Starting with version 2.7.0, the import engine has been re–written and these problems should not occur. If possible, upgrade your phpMyAdmin to the latest version to take advantage of the new import features.

The first things to check (or ask your host provider to check) are the values of upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP. One user also said that post_max_size and memory_limit need to be larger than upload_max_filesize.

There exist several workarounds if your upload is too big or your hosting provider is unwilling to change the settings:

Look at the $cfg['UploadDir'] feature. This allows one to upload a file to the server via scp, ftp, or your favorite file transfer method. PhpMyAdmin is then able to import the files from the temporary directory. More information is available in the Configuration section of this document.
Using a utility (such as BigDump) to split the files before uploading. We cannot support this or any third party applications, but are aware of users having success with it.
If you have shell (command line) access, use MySQL to import the files directly. You can do this by issuing the "source" command from within MySQL: source filename.sql.


I also tried changing ';enable_post_data_reading = OFF' to ON but it didn't help, so I changed it back.

I also tried changing
Quote:
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit

memory_limit = 128M' to -1M but it didn't help either.
I really have no idea what I am doing in there. I have now restored the original php.ini file for now.

I don't want a programmer to make the site and database changes for me but wish I knew one to hire to get xampp set up so I can do it myself.

(In that earlier post, I had typed just "I" because I wrote the post, then wanted to delete it but couldn't work out how to, so reduced it to one character, then re-edited it shortly after that.)

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

I have now managed to install the .sql file as a zipped file (.sql.zip), so I can now access the database via phpMyAdmin, but when I open my site's home page (stored in the xampp htdocs folder), I still only get the site's index.php file's php code showing in the browser, the home page (and all other non static pages) is not being created.

My site's cofig.php file now has
Quote:
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = 'esite';


originally, when on my webhost's server, it was...
Quote:
$dbHost = 'localhost';
$dbUser = 'esite';
$dbPass = 'xintox';
$dbName = 'esite';


How do I get the pages to display properly instead of just displaying their code?
I'm one step closer, now the database is set up, but what am I overlooking now?

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

I've been Googling like mad for days now but can't find an answer.

If anyone can tell me how to get the site's php files (in xampp's htdocs folder) to display as web pages when I open them in a browser instead of just showing the actual php code, I'd be eternally grateful.

I'm sure I am incorrectly doing something that is very basic.

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Aha.
I have just discovered something, it fixes one problem but shows up another.

I was using Chrome browser and now realise that if I open the php files in Firefox, they work (sort of), but if I open them in Chrome, they don't, they just display the code typed on the file. I have no idea why but at least I can use Firefox instead.

However, now that the index.php file opens, it displays an error stating...
Quote:
you have an error in your SQL syntax. Check the manual that corresponds to your MySQL server for the right syntax to use near " at line 3

and does not assemble the page completely.

I don't have a manual but, even if I did, I'm not sure I'd work out the problem.

I can't see what is wrong. Please tell me what code to show you to see if you can help. I am not sure if it is code in the index.php file, my config.php file or perhaps my database.php file.

I'll check back here tonight, as I have to stop for now.

Regards,
Cerio
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Ok, I have no idea where the problem is or how to fix it, as I don't know much about php or sql.

Here are the bits of the three php files that I wonder if the error can be found in. My database in xampp is called esite and the file I installed in it is called esite.sql.zip

I don't know if these pieces of code are helpful but here goes, as I have no idea how to fix...
Quote:

you have an error in your SQL syntax. Check the manual that corresponds to your MySQL server for the right syntax to use near " at line 3


These are the first 7 lines of my index.php file (the error above is displayed when I open it in the browser (localhost/index.php)
Code: [ Select ]
<?php
require_once 'library/config.php';
require_once 'library/category-functions.php';
require_once 'library/product-functions.php';
require_once 'library/cart-functions.php';

$_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];
  1. <?php
  2. require_once 'library/config.php';
  3. require_once 'library/category-functions.php';
  4. require_once 'library/product-functions.php';
  5. require_once 'library/cart-functions.php';
  6. $_SESSION['shop_return_url'] = $_SERVER['REQUEST_URI'];


These are the first 23 lines of my config.php file
Code: [ Select ]
<?php
ini_set('display_errors', 'On');
//ob_start("ob_gzhandler");
error_reporting(E_ALL);

// start the session
session_start();

$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = 'esite';

// setting up the web root and server root for
// this shopping cart application
$thisFile = str_replace('\\', '/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];

$webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
$srvRoot = str_replace('library/config.php', '', $thisFile);

define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
  1. <?php
  2. ini_set('display_errors', 'On');
  3. //ob_start("ob_gzhandler");
  4. error_reporting(E_ALL);
  5. // start the session
  6. session_start();
  7. $dbHost = 'localhost';
  8. $dbUser = 'root';
  9. $dbPass = '';
  10. $dbName = 'esite';
  11. // setting up the web root and server root for
  12. // this shopping cart application
  13. $thisFile = str_replace('\\', '/', __FILE__);
  14. $docRoot = $_SERVER['DOCUMENT_ROOT'];
  15. $webRoot = str_replace(array($docRoot, 'library/config.php'), '', $thisFile);
  16. $srvRoot = str_replace('library/config.php', '', $thisFile);
  17. define('WEB_ROOT', $webRoot);
  18. define('SRV_ROOT', $srvRoot);


These are the first 19 lines of my database.php file
Code: [ Select ]
<?php
require_once 'config.php';

$dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());

function dbQuery($sql)
{
    $result = mysql_query($sql) or die(mysql_error());
    
    return $result;
}

function dbAffectedRows()
{
    global $dbConn;
    
    return mysql_affected_rows($dbConn);
}
  1. <?php
  2. require_once 'config.php';
  3. $dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
  4. mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());
  5. function dbQuery($sql)
  6. {
  7.     $result = mysql_query($sql) or die(mysql_error());
  8.     
  9.     return $result;
  10. }
  11. function dbAffectedRows()
  12. {
  13.     global $dbConn;
  14.     
  15.     return mysql_affected_rows($dbConn);
  16. }


I made no changes to security in xampp.

I hope that information is enlightening enough. If anyone can work out the problem from these, I'd be very grateful.

Regards,
Cerio
  • Liamw411
  • Novice
  • Novice
  • Liamw411
  • Posts: 18
  • Loc: United Kingdom

Post 3+ Months Ago

Hi, don't know if you've managed to sort this but if you installed xampp correctly it should render your php files, sounds to me like you are trying to access the files directly and not via the server. Try http://127.0.0.1 or http://localhost/
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Thank you so much for your reply Liamw411. I did use http://localhost/.

Having had to leave it all for some months, I went back and tried again, just before I received your email, and oddly enough, it worked sort of (now have no idea what was wrong before but before I tried again, I replaced some of my site files with back-up ones and the error must have been on one that was overwritten by that) but there's a new problem. :?

I have noticed something puzzling; a section that works fine when the site is uploaded to my web host and online, does not display properly when viewed via XAMPP / localhost. The rest of the page displays perfectly and, as far as I've noticed so far, the rest of the site does too but, on every page that provides details of my items, there is this new problem, although there is no difference in code between the one online at my webhost's and the one viewed locally via XAMPP, so I don't understand why they display differently.

I can show you what I mean. The first photo is how it should look and how it is when actually uploaded and online, the second photo shows the problem when viewed locally on my computer, via XAMPP.
Below the photos is the code that creates that section.

When uploaded and online...


Image



When viewed locally via XAMPP (the NEW icons are explained below the picture)...

Image

Note - the correctly displayed photo (top one) does not [and should not] show a 'NEW' icon at all, because that item was added to the database more than 4 weeks ago. If it had been added within the last 4 weeks, it would show a little icon saying 'NEW', like in the picture below, the icon colour would depend on which week of those first 4 weeks it was at. The meaning of these icons and of their colours is explained elsewhere on the site.

Image


Below, you can see the code for that section of the page (exactly the same code is used in both the correctly displayed and the incorrectly displayed examples of the page). Note that the last part of the code ($pd_description etc) is not shown in the photos, as I cropped them to show just the faulty bit, but that bit of code is displaying correctly.

Code: [ Select ]
<?php
if (!defined('WEB_ROOT')) {
    exit;
}

$product = getProductDetail($pdId, $catId);
$shippingRow=$product;
// $pd_name, $pd_price, $pd_description, $pd_image, $cart_url
extract($product);
?>


<table bgcolor="FFFFFF" width="95%" border="0" cellspacing="0" cellpadding="3">
<tr> <a name="up">
 <td><img src="<?php echo $pd_image_path; ?>" width="286" height="341" border="0" alt="<?php echo $pd_name; ?>"></td>
 <td width="100%" valign="top">
<strong><?php echo $pd_name; ?></strong><br>
<?
//$today=date("Y-m-d");
$compareDate1=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-28,date("Y"))); // -28 = 4 weeks
$compareDate2=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-21,date("Y"))); // -21 = 3 weeks
$compareDate3=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-14,date("Y"))); // -21 = 3 weeks
$compareDate4=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-7,date("Y"))); // -21 = 3 weeks

// is it newer than 4 weeks?
if ($pd_date > $compareDate4)
  {echo "<img src='images/new1.gif' alt='new' /><br />";
  }
        // is it newer than 3 weeks?
elseif ($pd_date > $compareDate3)
  {echo "<img src='images/new2.gif' alt='new' /><br />";
  }
// is it newer than 2 weeks?  
elseif ($pd_date > $compareDate2)
  {echo "<img src='images/new3.gif' alt='new' /><br />";
  }
// is it newer than 1 week?  
elseif ( $pd_date > $compareDate1)
  {echo "<img src='images/new4.gif' alt='new' /><br />";
  }


?>
<font color="red"><strong>Item code:</strong></font> <? echo $pd_code;?><br />
<br><font color="red"><strong>Price:</strong></font> <?php echo displayAmount($pd_price); ?><br />
<br /><font color="red"><strong>Available:</strong></font> <? echo $pd_qty;?>
<br /><br /><font color="red"><strong>Shipping:</strong></font>

<br /><strong>UK:</strong></font> &pound;<?echo $pd_price_uk;?><br />
<strong>Europe:</strong> &pound;<?=$pd_price_eu?><br /><strong>Rest of World:</strong> &pound;<?=$pd_price_us?>
<br /><font color="red"><strong>Delivery OUTSIDE UK:</font></strong> buyer<strong> MUST </strong>also<br />purchase Mail Insurance<br />from the site's <a href="http://wafuku.co.uk/index.php?c=2083">Mail Insurance</a> section</font>
<br /><br />

<?php
// if still have this product in stock
// show the 'Add to cart' button
if ($pd_qty > 0) {
?>

<input type="button" name="btnAddToCart" value="Add To Cart &gt;" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
<?php
} else {
    echo "<strong><font color='#FF0000'>Sold</font></strong>";
}

?>
<br /><br /> Full postage &amp; insurance<br />details on Postage Page<br />

 </td>
</tr>
<tr align="left">
 <td colspan="2"><?php echo $pd_description; ?></td>
</tr>
</table>
  1. <?php
  2. if (!defined('WEB_ROOT')) {
  3.     exit;
  4. }
  5. $product = getProductDetail($pdId, $catId);
  6. $shippingRow=$product;
  7. // $pd_name, $pd_price, $pd_description, $pd_image, $cart_url
  8. extract($product);
  9. ?>
  10. <table bgcolor="FFFFFF" width="95%" border="0" cellspacing="0" cellpadding="3">
  11. <tr> <a name="up">
  12.  <td><img src="<?php echo $pd_image_path; ?>" width="286" height="341" border="0" alt="<?php echo $pd_name; ?>"></td>
  13.  <td width="100%" valign="top">
  14. <strong><?php echo $pd_name; ?></strong><br>
  15. <?
  16. //$today=date("Y-m-d");
  17. $compareDate1=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-28,date("Y"))); // -28 = 4 weeks
  18. $compareDate2=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-21,date("Y"))); // -21 = 3 weeks
  19. $compareDate3=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-14,date("Y"))); // -21 = 3 weeks
  20. $compareDate4=date("Y-m-d",mktime(0,0,0,date("m"),date("d")-7,date("Y"))); // -21 = 3 weeks
  21. // is it newer than 4 weeks?
  22. if ($pd_date > $compareDate4)
  23.   {echo "<img src='images/new1.gif' alt='new' /><br />";
  24.   }
  25.         // is it newer than 3 weeks?
  26. elseif ($pd_date > $compareDate3)
  27.   {echo "<img src='images/new2.gif' alt='new' /><br />";
  28.   }
  29. // is it newer than 2 weeks?  
  30. elseif ($pd_date > $compareDate2)
  31.   {echo "<img src='images/new3.gif' alt='new' /><br />";
  32.   }
  33. // is it newer than 1 week?  
  34. elseif ( $pd_date > $compareDate1)
  35.   {echo "<img src='images/new4.gif' alt='new' /><br />";
  36.   }
  37. ?>
  38. <font color="red"><strong>Item code:</strong></font> <? echo $pd_code;?><br />
  39. <br><font color="red"><strong>Price:</strong></font> <?php echo displayAmount($pd_price); ?><br />
  40. <br /><font color="red"><strong>Available:</strong></font> <? echo $pd_qty;?>
  41. <br /><br /><font color="red"><strong>Shipping:</strong></font>
  42. <br /><strong>UK:</strong></font> &pound;<?echo $pd_price_uk;?><br />
  43. <strong>Europe:</strong> &pound;<?=$pd_price_eu?><br /><strong>Rest of World:</strong> &pound;<?=$pd_price_us?>
  44. <br /><font color="red"><strong>Delivery OUTSIDE UK:</font></strong> buyer<strong> MUST </strong>also<br />purchase Mail Insurance<br />from the site's <a href="http://wafuku.co.uk/index.php?c=2083">Mail Insurance</a> section</font>
  45. <br /><br />
  46. <?php
  47. // if still have this product in stock
  48. // show the 'Add to cart' button
  49. if ($pd_qty > 0) {
  50. ?>
  51. <input type="button" name="btnAddToCart" value="Add To Cart &gt;" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
  52. <?php
  53. } else {
  54.     echo "<strong><font color='#FF0000'>Sold</font></strong>";
  55. }
  56. ?>
  57. <br /><br /> Full postage &amp; insurance<br />details on Postage Page<br />
  58.  </td>
  59. </tr>
  60. <tr align="left">
  61.  <td colspan="2"><?php echo $pd_description; ?></td>
  62. </tr>
  63. </table>


I would be very grateful if anyone could tell me why they display differently.

Regards,
Cerio
  • Liamw411
  • Novice
  • Novice
  • Liamw411
  • Posts: 18
  • Loc: United Kingdom

Post 3+ Months Ago

If it is the same code you are using on both, the issue may be that you have different versions of php on your server and your local machine.
Make a php info page and check to see if the versions are identical?.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Ah. Thank you.
My web host has php 5.3.3 and XAMPP has 5.4.4. So it is the 5.4.4 that it is not rendering properly on.
Anything I can do to ensure it works on both (bearing in mind that I really know nothing about php code)?
  • Liamw411
  • Novice
  • Novice
  • Liamw411
  • Posts: 18
  • Loc: United Kingdom

Post 3+ Months Ago

Easiest way to fix would be to copy all files and databases, uninstall xampp and download and install a version that has php 5.3.3. And then replace files + databases.
  • cerio
  • Proficient
  • Proficient
  • User avatar
  • Posts: 263
  • Loc: UK

Post 3+ Months Ago

Thank you, Liamw411. That will sort things out for me while I work on it, so I may do that.

I wonder, however, if my web host and others may all start using php 5.4.4 sometime, causing the problem to eventually resurface online. Perhaps, to make it future-proof, I need to find a way to fix the problem of how it renders in 5.4.4.

Regards,
Cerio
  • dickot
  • Born
  • Born
  • dickot
  • Posts: 1

Post 3+ Months Ago

I found myself in exactly the same situation.
I dont know how far you got but check your php.ini file and look for "short_open_tag".
If you have the php open tag "<?" anywhere you will need to set that directive to "On".
Try changing it and re-starting Apache, then see how the page loads.

Post Information

  • Total Posts in this topic: 23 posts
  • Users browsing this forum: No registered users and 89 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.