Updated PHP MySQL and Xampp now no database content visible

I purposely broke the code and removed a ; and received an error message when I reloaded the page, so that part works.

I have a number of “includes” in the code which all work except one. this is directly after the query, however all of the includes “After” that section still work. In the past if there is an error in any of the code there will be an error messages somewhere even if most of the page working like if the query refers to somewhere not available like prod_table instead of prod-table, in the past the page will load but an error within the page will appear. The code block below is the part in question:

<?php include ('prodlabels.php');?><?php // This displays ?>
<?php // From here down doesnt display ?> <?php // Queries All Products where they are Featured or on Special $result = mysql_query("SELECT * FROM products WHERE SpecFeat = 'YES' ") or trigger_error (mysql_error()); while ($row=mysql_fetch_assoc($result)// I tried a ; here and it returned an error)// I also tried a ; here but it made no difference { include ('tablelogincheck.php'); } ?>
  </div><!-- prod -->
  <? include ('prodbot.php');?>
</div><!--mainbod-->

After this code, there are some closing “Div” tags and then a further “include” which does display, which sort of indicates that there are no “noticeable” errors all my pages have similar code and all have the same problem. When I am logged in I can view my account details so the site is actually able to pull data from the database. I have also tried substituting $result with $sql (as it is in my customer query code)

<?php $sql = mysql_query("SELECT * FROM customer WHERE UserName='" . $_SESSION['UserName'] . "' LIMIT 1"); while($row = mysql_fetch_assoc($sql)){ ?>

Again no difference and no errors. Tried all that so I am at a loss really.

for the include tablelogincheck.php

<? //Checks to see if user is logged in if(!empty($_SESSION['UserName'])) $user = $_SESSION['UserName']; if (isset($_SESSION['UserName'])){ // Product Table for customer that has logged in (displays "add to cart" button) include ('tableli.php'); } else{ // Product Table for customer that is not logged in ("add to cart" button is not visible) include ('table.php'); } ?>

I broke the above code and there were no errors displayed.

I removed the ; after the line $user = $_SESSION[‘UserName’]; no error displayed

I changed UserName to UserNam, no error displayed
So I as changing/breaking this code made no difference I can only assume the problem is before this code, that is is not actually being “included”??

Add the four lines below the underneath the mysql_query call.

The print_r should print out the entire data set if anything is returned.

[php] $result = mysql_query("SELECT * FROM products WHERE SpecFeat = ‘YES’ ") or trigger_error (mysql_error());
echo 'Displaying Results
';
print_r($result);
echo ‘
Results Displayed’;
exit;
[/php]

Thankyou for that but this used to display the content i wanted it to but now it doesn’t

tablei.php is

<?php echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; echo '
'.$row['Brand'].''.$row['ModelVersion'].''.$row['ShortDesc'].''.$row['ImgM'].'$ '.$row['OurPrice'].''.$row['Astr'].'
'; //
View Larger
?>

table.php is

<?php echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; echo '
'.$row['Brand'].''.$row['ModelVersion'].''.$row['ShortDesc'].''.$row['ImgM'].'$ '.$row['OurPrice'].''.$row['Astr'].'
'; //
View Larger
?>

I can only help you, if you do what I ask.

I did try your code and it displayed
Displaying Results
Resource id #10
Results Displayed

But no data, as it is not formatted though, it does change the appearance of the page, it removes the footer of my page i removed the exit; and page footer was visible, still no data displayed though.

Now do this… I changed 1 line.

[php]$result = mysql_query("SELECT * FROM products WHERE SpecFeat = ‘YES’ ") or trigger_error (mysql_error());
echo 'Displaying Results
';
print_r(mysql_fetch_assoc($result));
echo ‘
Results Displayed’;
exit;
[/php]

this displayed 1 item not formatted of course, however there are actually about 9 items that actually fit the search parameters, but it does actually display data

Displaying Results
Array ( [ProductId] => 17 [Brand] => Asus [Category] => Desktop Desktops All In One All In Ones [ModelVersion] => ET2700 [Item] => Desktop [ItemType] => All-In-One [FullDesc] => Windows 7 Professional 64 BitIntel Core i7-2600 CPU27" LED Backlit 1920 x 1080 (Non Touch)6GB Ram2TB [StockCount] => 12 [Astr] => * [OurPrice] => 2185.00 [SpecFeat] => YES [ShortDesc] => 27" All-In-One Desktop Computer Win 7 Pro [ImgM] => [Thumb] => )
Results Displayed

At the end of the day though, I am really amazed how simply updating Xampp/PHP/MySql would cause such a calamity.

It all worked fine in Xampp 1.7.7 and PHP 4.0.8… I have the earlier versions on my laptop and it all works fine…

i never had this much of a problem when updating in the past

Yeah mysql_fetch_assoc only returns 1 row, so at least we know you’re pulling back data from the database. That’s a good sign :slight_smile:

I actually don’t see anything that will cause it not to display the data…

When it displays the blank page and you right click, view source? Do you see anything?

the display area is between

and its closing tag

The source shows this between the tags: <? //Checks to see if user is logged in if(!empty($_SESSION['UserName'])) $user = $_SESSION['UserName']; if (isset($_SESSION['UserName'])){ // Product Table for customer that has logged in (displays "add to cart" button) include ('tableli.php'); } else{ // Product Table for customer that is not logged in ("add to cart" button is not visible) include ('table.php'); } ?><? //Checks to see if user is logged in
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?><? //Checks to see if user is logged in 
          if(!empty($_SESSION['UserName']))
          $user = $_SESSION['UserName'];
          if (isset($_SESSION['UserName'])){
          // Product Table for customer that has logged in (displays "add to cart" button)
          include ('tableli.php');
          }
          else{
          // Product Table for customer that is not logged in ("add to cart" button is not visible)
          include ('table.php');
         }
		 ?>     

so it seems there is a problem in the tablelogincheck.php ??

which is the actual code for the tablechecklogin.php

That’s not the HTML Source…

When you run it in the browser and the page is blank, right click on the browser and select view source.

UGGGHHHH >:( :o ??? I looked at the code in the tablechecklogin.php"

<? //Checks to see if user is logged in if(!empty($_SESSION['UserName'])) $user = $_SESSION['UserName']; if (isset($_SESSION['UserName'])){ // Product Table for customer that has logged in (displays "add to cart" button) include ('tableli.php'); } else{ // Product Table for customer that is not logged in ("add to cart" button is not visible) include ('table.php'); } ?>

Changed the first <? to <?php and it looks like it may have fixed the problem

<?php //Checks to see if user is logged in if(!empty($_SESSION['UserName'])) $user = $_SESSION['UserName']; if (isset($_SESSION['UserName'])){ // Product Table for customer that has logged in (displays "add to cart" button) include ('tableli.php'); } else{ // Product Table for customer that is not logged in ("add to cart" button is not visible) include ('table.php'); } ?>

I feel like a bit of a dill now… something so damned simple

Yeah that’s a common issue, you have to turn on short tags in the PHP.ini to use the short tags.

True but it’s probably better practice to use long tags, as while it is on your system it may work.
But if what ever server you eventually load it up to isn’t set up like that it can cause problems.

I think I noted that it is the only short tag on my entire site…

Thanks for your help, hopefully it could be useful to your knowledge-base as well??

Yeah, I should write up and maintain a post on most common issues…

Thanks again for your time and help I do appreciate it.

FIY: the short-hand echo’s are now taken out of the “short tag” setting and are still available. There are no plans to remove them in the future so they should be safe to use.

[php]

My template


<?= $description ?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service