PHP behaving strangely

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP behaving strangely

Postby ElfN » 21. December 2010 18:52

I've had an older version of xampp running on my system for over a year. I've uninstalled the old and installed the new ver (1.7.3) and now php doesn't produce the same result.

http://slipperycritters.com/index.php gives me what I would expect for the current state of the programming. On my local system, I get the following (ugly)

Slippery Critters
Clean fun in the tub!

Home

Policy

Shopping Cart
"; $cnt=1; echo"\n\t\t"; do { $ID=$stock[ID]; $this_item_array=mysql_query("SELECT * FROM `SC_Images` where `StockID` = '$ID' and `SortOrder` = '0' limit 0,1"); $this_item=mysql_fetch_array($this_item_array); $img=explode("_", $this_item[Image]); $img=array_reverse($img); $tn=$this_item[ID]."_TN_".$img[0]; $image=$this_item[Image]; if ($cnt==1) { echo "\n\t\t \n\t\t\t "; } else { echo " "; } echo "
"; if (file_exists("StoreImages/$tn")) { echo""; } echo "
$stock[Name]
"; if ($cnt == 3) { $cnt=1; echo " \n\t\t
\n"; } else { $cnt++; echo "\n\t\t\t"; } } while ($stock=mysql_fetch_array($ss)); if ($cnt==2) { echo " "; } elseif($cnt==3) { echo " "; } echo "
\n\t\t"; } } }else { //2nd if $qry="select * from `SC_Gifts` where `ID` = '$i'"; $q2="SELECT * FROM `SC_Images` where `StockID` = '$i' order by `SortOrder` limit 0,1"; $ss=mysql_query($qry,$db) or die ("Couldn't retrieve catalog item. $qry"); $is=mysql_query($q2,$db) or die ("Couldn't retrieve header image. $q2"); $stock=mysql_fetch_array($ss); //Display item $image=mysql_fetch_array($is); //Header image ; //Image list echo ""; if (file_exists("StoreImages/$image[Image]")) { echo "
"; } echo "
$stock[Name]
"; echo '
'; $ex_filter=$image[ID]; $q3="SELECT * FROM `SC_Images` where `StockID` = '$i' and `ID` != '$ex_filter' order by `SortOrder`"; $mi=mysql_query($q3,$db) or die ("Couldn't retrieve images list. $q3"); $icnt=0; while ($i_list=mysql_fetch_array($mi)) { if ($icnt == 0) { // set up a floating div to hold the images? echo "\n\t\t

\n"; } $icnt++; //create and test for thumbnail $iarray=explode("_",$i_list[Image]); $TN=$iarray[0]."_TN_".$iarray[1]; if (file_exists("StoreImages/$TN")) { if ($i_list[Caption] > '') { $trunc = strip_tags($i_list[Caption]); // get rid of the html, because javascript doesn't translate it $trunc = str_replace("'", "'", $trunc); $trun = htmlspecialchars($trunc); } echo "\t\t\t\n"; } } if ($icnt > 0) { echo "\n\t\t\n"; } echo $stock[Description]; echo "
"; if ($stock[Price] > '0.00') { echo "
"; echo "$".$stock[Price].""; echo ""; echo ""; echo ""; echo ""; echo "

Quantity: "; echo "


"; } echo "

"; } //endif echo "
Visitors since 09-26-2007 - "; include("../inc/HitCounter.inc"); echo "
"; ?>
Site design by OfficeElf.


Any idea why the php is failing to run? I can go to localhost and pull up phpinfo and it looks okay . . . I think. Ideas?
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP behaving strangely

Postby JonB » 21. December 2010 19:22

Are you using Short Open tags?
:shock:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: PHP behaving strangely

Postby ElfN » 21. December 2010 19:59

Short open tags is off
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP behaving strangely

Postby WilliL » 21. December 2010 21:00

you didn't answered JonB's question ;)

starting your php scripts '<?' means you are using short open tags, '<?php' means you are not using them.

If you are using short open tags switch it on, in earlier versions of xampp it was switched ON, since 1.7.3 its switched of
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP behaving strangely

Postby Altrea » 22. December 2010 16:31

WilliL wrote:...since 1.7.3 its switched of

just a small correction:
It wasn't (only) a XAMPP decission to switch short_open_tags to off.
short_open_tags and some other PHP settings are set to off by default since PHP version 5.3.0.
And the first XAMPP version with PHP 5.3 was XAMPP 1.7.2.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP behaving strangely

Postby WilliL » 22. December 2010 18:14

:oops:
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP behaving strangely

Postby ElfN » 22. December 2010 20:57

Short_open_tags did nothing. Doesn't matter if I'm using <? or <?php. Doesn't matter if I change the php.ini short_open_tags on or off. That doesn't appear to be the problem. Any other ideas?
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP behaving strangely

Postby WilliL » 22. December 2010 23:08

ElfN wrote: Any other ideas?
How?
you could show us the script, you could look, if there are informations in error.log, you could have a look in phpinfo() to ensure that you edited the correct php.ini, you could give information if you'd changed any configuration...
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP behaving strangely

Postby ElfN » 22. December 2010 23:54

I'm more than happy to give you the whole script, though that isn't the problem. The script works perfectly on the online server (link in first post). I've done a search for php.ini and I appear to have only one, though I make changes to it and the changes do not appear in the php info in the xampp panel.

The original install had no problems. I used it for over a year without issue. This one is really baffling me.

Here's the page's code.

<?PHP
include('../inc/dbconnect.inc');
include('inc/settings.inc');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Slippery Critters Gifts </TITLE>
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="lightbox/prototype.js"></script>
<script type="text/javascript" src="lightbox/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="lightbox/lightbox.js"></script>
<link rel="stylesheet" href="lightbox/lightbox.css" type="text/css" media="screen">
<LINK REL="stylesheet" HREF="css.php" TYPE="text/css">
</HEAD>

<BODY style="background:#fff url('images/BG.gif');">
<div align=center>
<table width='100%' style='margin:10px;' cellpadding='12' align='center'>
<tr><td colspan='2' style='text-align:center;font-family:comic sans MS;font-weight:bold;border-bottom: black 4px solid;'><span style='font-size:46px;color:green;font-style:italic;'>Slippery Critters</span><p><span style='font-size:28px;color:red;'>Clean fun in the tub!</span></td></tr>
<tr><TD width='200px' valign='top' style='font-size:22px;'>
<p><a href="index.php">Home</a>
<p><a href="index.php?q=policy">Policy</a>
<?php

$result=mysql_query("select distinct(Category) from `SC_Gifts` where `Display`='Y' group by `Category` order by `SortOrder`",$db);

if ($myrow=mysql_fetch_array($result)) {

do {
echo " <p><a href='index.php?q=$myrow[Category]'> $myrow[Category] </a><br>";

} while ($myrow=mysql_fetch_array($result));
}

?>
</nobr>
<p><A HREF='http://ww4.aitsafe.com/cf/review.cfm?userid=64159964' target=_blank>Shopping Cart</a></span>

</td><td class='content'><div style='padding:6px 20px 20px 20px;'>

<?PHP

if (!$i) { //if i
if ((!$q || $q == 'home')) { //outside if
include ('home.htm');
} elseif ($q == 'policy') {
include ('policy.htm');
} else { //2nd if

$qry="select * from `SC_Gifts` where Category = '$q' and Display='Y' order by `SortOrder`";

$ss=mysql_query($qry,$db);

if ($stock=mysql_fetch_array($ss)) {
echo "<h2>".$stock[Category]."</h2>";
$cnt=1;
echo"\n\t\t<table align=center cellpadding=6>";
do {
$ID=$stock[ID];
$this_item_array=mysql_query("SELECT * FROM `SC_Images` where `StockID` = '$ID' and `SortOrder` = '0' limit 0,1");
$this_item=mysql_fetch_array($this_item_array);
$img=explode("_", $this_item[Image]);
$img=array_reverse($img);
$tn=$this_item[ID]."_TN_".$img[0];
$image=$this_item[Image];
if ($cnt==1) {
echo "\n\t\t<tr>\n\t\t\t<td>";
} else {
echo "<td>";
}
echo "<div class='stock'><a href='index.php?i=$ID'>";
if (file_exists("StoreImages/$tn")) {
echo"<img class=tn id=tn src='StoreImages/$tn'>";
}
echo "<h3>$stock[Name]</h3></a></div>";
if ($cnt == 3) {
$cnt=1;
echo "</td>\n\t\t</tr>\n";
} else {
$cnt++;
echo "</td>\n\t\t\t";
}
} while ($stock=mysql_fetch_array($ss));
if ($cnt==2) {
echo "<td>&nbsp;</td><td>&nbsp;</td>";
} elseif($cnt==3) {
echo "<td>&nbsp;</td>";
}
echo "</tr></table>\n\t\t";
}

}
}else { //2nd if

$qry="select * from `SC_Gifts` where `ID` = '$i'";
$q2="SELECT * FROM `SC_Images` where `StockID` = '$i' order by `SortOrder` limit 0,1";

$ss=mysql_query($qry,$db) or die ("Couldn't retrieve catalog item. <span style='color:red;'>$qry</span>");
$is=mysql_query($q2,$db) or die ("Couldn't retrieve header image. <span style='color:red;'>$q2</span>");

$stock=mysql_fetch_array($ss); //Display item
$image=mysql_fetch_array($is); //Header image
; //Image list

echo "<div class='stock' style='width:520px;'>";
if (file_exists("StoreImages/$image[Image]")) {
echo "<img src='StoreImages/".$image[Image]."' align=left hspace=10><br clear=left>";
}
echo "<h3>$stock[Name]</h3>";
echo '<p>';
$ex_filter=$image[ID];
$q3="SELECT * FROM `SC_Images` where `StockID` = '$i' and `ID` != '$ex_filter' order by `SortOrder`";
$mi=mysql_query($q3,$db) or die ("Couldn't retrieve images list. <span style='color:red;'>$q3</span>");
$icnt=0;
while ($i_list=mysql_fetch_array($mi)) {
if ($icnt == 0) { // set up a floating div to hold the images?
echo "\n\t\t<div style='float:left;width:200px;'>\n";
}
$icnt++;
//create and test for thumbnail
$iarray=explode("_",$i_list[Image]);
$TN=$iarray[0]."_TN_".$iarray[1];
if (file_exists("StoreImages/$TN")) {
if ($i_list[Caption] > '') {
$trunc = strip_tags($i_list[Caption]); // get rid of the html, because javascript doesn't translate it
$trunc = str_replace("&#39;", "'", $trunc);
$trun = htmlspecialchars($trunc);
}
echo "\t\t\t<a href='StoreImages/$i_list[Image]' rel='lightbox' title='$i_list[Caption]'><img class=tn src='StoreImages/$TN' border=0 hspace=4 vspace=4 alt='$trun' caption='$i_list[Caption]'></a>\n";
}
}
if ($icnt > 0) {
echo "\n\t\t</div>\n";
}
echo $stock[Description];
echo "<p>";
if ($stock[Price] > '0.00') {
echo "<FORM METHOD=\"POST\" ACTION=\"http://ww4.aitsafe.com/cf/add.cfm\" target=_blank>";
echo "<b>$".$stock[Price]."</b>";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"userid\" VALUE=\"64159964\">";
echo "<input type=hidden name=return value=slipperycritters.com/index.php>";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"product\" VALUE=\"" . $stock[StockID] . " " . $stock[Name]. "\">";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"price\" VALUE=\"" . $stock[Price] . "\">";
echo "<p>Quantity: <input name='qty' type='text' value=1 size=2>";
echo "<p><input type=\"submit\" value=\"buy now\" name=\"add\"></form>";
}
echo "<br clear=all></div>";
} //endif
echo "<div align=center style='margin-top:20px;'><span style=\"background-color:#D8DFDE;color:#006A48;padding:4px;border:1px solid #006A48;\"> &nbsp; <FONT SIZE=-1>Visitors since 09-26-2007 -</FONT> <b>";
include("../inc/HitCounter.inc");
echo "</b> &nbsp; </span></div>";
?>
<p style='font-size:9pt;text-align:center;'>Site design by <a href="http://www.officeelf.com">OfficeElf</a>.
</td></tr></table>
<p align=left style='color:#CDE4CB;font-weight:bold;'><span style='border:1px solid #FFFFFF;padding:4px;background-color:#FFF;margin-bottom:6px;'><IMG SRC="images/NAWBO.jpg" WIDTH="150" HEIGHT="51" BORDER="0" ALT="National Association of Women Business Owners"></span><br>
National Association of<br>Women Business Owners
</div>

</BODY>
</HTML>
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP behaving strangely

Postby Altrea » 22. December 2010 23:58

Your Script looks fine. My Questions:

How do you request/open the script locally in your Browser?
Which file extension does the file have?

P.S.: next time please use the code-BBCodes. With the BBCodes you can see white spaces and so on which gives a better overview through your script
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP behaving strangely

Postby ElfN » 23. December 2010 00:23

The file extension is php. I used EditPlus as my editor. I hit the browser button and the file flips from edit to open (internal IE instance). That's the way I've always done it. Previous install worked perfectly, this one, not so much <wince>.

Just so you have the full scope of the issue, I was working on another client's site last week and had exactly the same problem . . . the php script dies part way through and the code is exposed. That site is http://www.genevieveflynn.com. To get to the php page (site opens in index.html) you have to select a menu item which leads to a much more complex setup. Won't open properly on my local xampp install but works perfectly online.

And where the code breaks makes NO sense. There isn't an error there, it's just as if it will only parse so much code, then it dies. Or it's not connecting to the mysql database. That's totally possible. In my local instance of Slippery Critters the menu isn't being populated (php coding uses categories in the table to produce the menu).
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14

Re: PHP behaving strangely

Postby Altrea » 23. December 2010 00:36

I don't know EditPlus.
Just to be sure if thats a XAMPP issue or EditPlus Issue please save your php file into your htdocs folder and request it the manual way (open your Browser, request your file => http://localhost/filename.php).

How can you configure EditPlus where your webserver and php parser is running (or does it simply use the localhost http request?)
Maybe EditPlus has some problems with the portable nature of XAMPP (no Registry entrys).
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8290
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP behaving strangely

Postby ElfN » 23. December 2010 00:48

Crap, crap, crap. Internal browser issue. Thanks. I changed nothing in EditPlus, but this install of xampp requires something different. I am clueless what is required, but at least I now have someplace to look. Thanks.
ElfN
 
Posts: 19
Joined: 06. May 2009 20:14


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 34 guests