Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

10 posts by 2 authors in: Forums > CMS Builder
Last Post: April 1, 2014

Here is the response from my server admins:

We regret to hear you're experiencing issues with the script at [ http://www.trinicarsforsale.com/database/featured_section.php ]. We created a custom PHP.ini in the home directory for this user, where a memory limit can be set. This was increased all the way of to 1024mb, but there was no change in the error. Unfortunately it is unclear as to what is consuming so much memory - we would recommend reviewing the PHP scripts referenced in the memory allocation error.

Hiarifkhayam,

Can you upload the source code of that page as an attachment? We can have a look to see what might be wrong.

All the best,
Chris

<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
require_once "/home/tcfs/public_html/cmsAdmin/lib/viewer_functions.php";

list($featured_carsRecords, $featured_carsMetaData) = getRecords(array(
'tableName' => 'featured_cars',
'where' => 'featured_ad = 1',
'orderBy' => 'RAND()',
'allowSearch' => '0',
));

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body topmargin="0">
<div align="left">
<table width="730" border="0" cellspacing="0" cellpadding="5" bgcolor="#ff3232">
<tr>
<td><b><font size="4" color="white" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">FEATURED ADS</font></b></td>
</tr>
<tr>
<td bgcolor="white"><marquee height="165" scrolldelay="200" width="720" bgcolor="white">
<table width="360" border="0">
<tr><?php $currentDateTime = time(); ?><?php foreach ($featured_carsRecords as $record): ?><?php if (strtotime($record['featuredStartDate']) <= $currentDateTime && strtotime($record['featuredEndDate']) >= $currentDateTime): ?>
<td width="360">
<table width="360" border="0" cellspacing="0" cellpadding="0">
<tr height="120">
<td valign="top" width="172" height="120"><?php foreach ($record['main_photo'] as $upload): ?><?php if ($upload['hasThumbnail']): ?><a href="<?php echo $record['_link'] ?>" target="_blank"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="160" height="120" border="1" alt="" hspace="5" vspace="15" /></a><?php elseif ($upload['isImage']): ?><img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><?php else: ?><a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><?php endif ?><?php break; ?><?php endforeach ?><br />
</td>
<td valign="top" width="188" height="120"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">
<table border="0" cellspacing="0" cellpadding="0">
<tr height="15">
<td align="left" valign="top" width="58" height="15"></td>
<td align="left" valign="top" width="129" height="15"></td>
</tr>
<tr height="20">
<td colspan="2" align="left" valign="top" width="187" height="20"><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><a href="<?php echo $record['_link'] ?>" target="_blank"><?php echo $record['main_id'] ?></a></b></font><?php
$secondsOld = time() - strtotime($record['date_added']);
$daysOld = intval($secondsOld/60/60/24);
?><?php if ($daysOld <= 7): ?> <img src="new.gif" alt="" height="12" width="31" border="0" /><?php endif ?></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Make:</b></font></td>
<td align="left" valign="top" width="129" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><?php echo $record['make_of_car'] ?></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Model:</b></font></td>
<td align="left" valign="top" width="129" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><?php echo $record['model_of_car'] ?></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Series:</b></font></td>
<td align="left" valign="top" width="129" height="20"><?php echo $record['license_plate_no'] ?></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Price:</b></font></td>
<td align="left" valign="top" width="129" height="20"><font size="2" color="red" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>$<?php echo number_format ($record['asking_price'] ,0) ?><?php echo $record['price_details'] ?></b></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="58" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Contact:</b></font></td>
<td align="left" valign="top" width="129" height="20"><?php echo $record['contact_phone_nos'] ?></td>
</tr>
</table>
</font></td>
</tr>
<tr height="1">
<td colspan="2" valign="top" bgcolor="#d9dadc" width="360" height="2"></td>
</tr>
</table>
<?php endif ?></td>
<?php $maxCols=1000; if (@++$count % $maxCols == 0): ?></tr>
<tr><?php endif; ?><?php endforeach ?></tr>
</table>
</marquee></td>
</tr>
<tr>
<td><b><font size="4" color="white" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">FEATURED ADS</font></b></td>
</tr>
</table>
</div>
</body>
</html>

Attachments:

featured_section.php 6K

Everything was working great until I did an upgrade to my cmsAdmin yesterday.

Hi arifkhayam,

I don't see anything wrong with your page.

Could you please fill out a second level support request with your FTP information so we can take a closer look?

https://www.interactivetools.com/support/email_support_form.php?message=http://www.interactivetools.com/forum/forum-posts.php?postNum=2233560

Thanks!

All the best,
Chris

Thank you. Support request sent.

By Chris - March 31, 2014 - edited: March 31, 2014

Hi arifkhayam,

Thanks for the FTP details — I was able to check a couple of things out and I've fixed that page. 12,325 is a lot of records! Since the logic in your FOREACH (regarding featuredStartDate, featuredEndDate, and the current time) currently ignores all but 30 of those records, moving that filtering condition into your WHERE clause yields massive improvements. I changed the 'where' line in your getRecords() call near the top of the script and it seems to work much better now!

Here's what it was:

'where' => 'featured_ad = 1',

And here's what it is now:

'where' => 'featured_ad = 1 AND featuredStartDate < NOW() AND NOW() < featuredEndDate',

The IF condition is now redundant, but I left it in there in case you need to reference it for any reason.

Hope this helps!

All the best,
Chris

Thank you Chris for sorting this out for me. I have one other page which has basically the same function with the start and end date. Do you think I should edit the code on that page using the same format as shown before?

Here is the page:

http://www.trinicarsforsale.com/database/premium_section.php

Here is the relevant code:

list($featured_carsRecords, $featured_carsMetaData) = getRecords(array(
'tableName' => 'featured_cars',
'where' => 'premium_ad = 1',
'orderBy' => 'RAND()',
'allowSearch' => '0',
));

Yes, absolutely. Just make the same change to the 'where' line as above.

The more filtering you can do on the database side, the faster your page will be and the less memory it will use.

All the best,
Chris