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


- Joined: Feb 07, 2004
- Posts: 263
- Loc: UK
- Status: Offline
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...
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)
These are the first 23 lines of my config.php file
These are the first 19 lines of my database.php file
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
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'];
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'];
- <?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'];
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);
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);
- <?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);
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);
}
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);
}
- <?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);
- }
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
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
September 27th, 2012, 9:05 pm
- Liamw411
- Newbie


- Joined: Oct 18, 2012
- Posts: 5
- Status: Offline
- cerio
- Proficient


- Joined: Feb 07, 2004
- Posts: 263
- Loc: UK
- Status: Offline
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...

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

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.

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.
I would be very grateful if anyone could tell me why they display differently.
Regards,
Cerio
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...

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

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.

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> £<?echo $pd_price_uk;?><br />
<strong>Europe:</strong> £<?=$pd_price_eu?><br /><strong>Rest of World:</strong> £<?=$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 >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
<?php
} else {
echo "<strong><font color='#FF0000'>Sold</font></strong>";
}
?>
<br /><br /> Full postage & insurance<br />details on Postage Page<br />
</td>
</tr>
<tr align="left">
<td colspan="2"><?php echo $pd_description; ?></td>
</tr>
</table>
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> £<?echo $pd_price_uk;?><br />
<strong>Europe:</strong> £<?=$pd_price_eu?><br /><strong>Rest of World:</strong> £<?=$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 >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
<?php
} else {
echo "<strong><font color='#FF0000'>Sold</font></strong>";
}
?>
<br /><br /> Full postage & insurance<br />details on Postage Page<br />
</td>
</tr>
<tr align="left">
<td colspan="2"><?php echo $pd_description; ?></td>
</tr>
</table>
- <?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> £<?echo $pd_price_uk;?><br />
- <strong>Europe:</strong> £<?=$pd_price_eu?><br /><strong>Rest of World:</strong> £<?=$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 >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
- <?php
- } else {
- echo "<strong><font color='#FF0000'>Sold</font></strong>";
- }
- ?>
- <br /><br /> Full postage & insurance<br />details on Postage Page<br />
- </td>
- </tr>
- <tr align="left">
- <td colspan="2"><?php echo $pd_description; ?></td>
- </tr>
- </table>
I would be very grateful if anyone could tell me why they display differently.
Regards,
Cerio
- Liamw411
- Newbie


- Joined: Oct 18, 2012
- Posts: 5
- Status: Offline
- cerio
- Proficient


- Joined: Feb 07, 2004
- Posts: 263
- Loc: UK
- Status: Offline
- Liamw411
- Newbie


- Joined: Oct 18, 2012
- Posts: 5
- Status: Offline
- cerio
- Proficient


- Joined: Feb 07, 2004
- Posts: 263
- Loc: UK
- Status: Offline
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
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


- Joined: Jan 03, 2013
- Posts: 1
- Status: Offline
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.
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.
1, 2
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 23 posts
- Users browsing this forum: No registered users and 303 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
