Wordpress Timeout - php

I am a back end dev for a WordPress website: https://westtechshipping.com.
The admin side is where the majority of our time is spent. We deal with packages ordered by our customers and deliver them. I have a system put in place where you upload a .csv file and the PHP function reads the contents of the .csv, then updates the data into the database, then sends out an email to our clients.
Over time we realized that we cannot do a .csv upload with more than 30 entries because we would get errors like this one
I took this image from google images because I cannot recreate the error at the moment due to the time of this post, but the error is similar.
We also sometimes get a page that says this
We've tried many things and are not sure what the issue is. These hiccups cause our data to be uploaded twice and multiple emails to be sent out to each client.
We have spoken to our server hosting, go daddy, and followed their recommendations of editing our user.ini accordingly.
This are our PHP settings from our user.ini
If this is an issue with the code, below is the current code for our .csv upload feature.
if(isset($_POST["submitcsv"])) // Upload Package Amount CSV File
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file, "r");
$c = 0;
$c2 = 0;
$row = 1;
while(($filesop = fgetcsv($handle, 1000, ",")) !== false)// What?
{
$Name = $filesop[0];
$AccID = $filesop[1];
$Freight = $filesop[2];
$Handling = $filesop[3];
$Consolidation = $filesop[4];
$Duty = $filesop[5];
$VTax = $filesop[6];
$Delivery = $filesop[7];
$Insurance = $filesop[8];
$Amount = $filesop[9];
$Statuscsv = $filesop[10];
$Pickup = $filesop[11];
$trackingnumber =$filesop[12];
if($row == 1) { $row++; continue;}
$num = count($filesop);
//Separating First name
$First_Name = substr($Name,0,strrpos($Name,' '));
if(strrpos($Name, ' ')!== false){
$First_Name = $First_Name;
}else{
$First_Name = $Name;
}
//Getting rid of blank costs
if(empty($Freight)){$Freight = "0";}
if(empty($Handling) ){$Handling = "0";}
if(empty($Consolidation)){$Consolidation = "0";}
if(empty($Duty) ){$Duty = "0";}
if(empty($VTax) ){$VTax = "0";}
if(empty($Delivery)){$Delivery = "0";}
if(empty($Insurance)){$Insurance = "0";}
if(empty($Amount)){$Amount = "0";}
//$pkg = get_packages_query($trackingnumber);
//$pkginv = get_invoices_by_trackingid($trackingnumber);
$userID = explode('WT100',$AccID);
$userdata = get_userdata( $userID[1] );
$site_name = get_bloginfo('name');
$messageinv = " <style>
#media screen (max-width:768px) { /* smartphones, iPhone, portrait 480x320 phones */
#packagetable{
margin-left:20px;
}
}
</style>
<div style='font-size:15px;'>
<strong> Dear ".$First_Name."</strong>, <br><br>
".$site_name." has a package available for you. You can come in to collect during our working hours of Monday- Friday 8AM to 5PM and Saturdays 9AM to 1PM.
</div>
<br><br>
<table id='packagetable' style='border:1px solid #8EAADB; margin-left:150px;'>
<tr class ='invhead' style='background-color:#4472C4; color:white;'>
<th>Charges</th>
<th>Amount (EC)</th>
</tr>
<tr class ='2ndtr' >
<td > Tracking Number </td>
<td> ".$trackingnumber."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Shipping Charge: </td>
<td> $".$Freight." </td>
</tr>
<tr class ='2ndtr' >
<td > Duty Charge: </td>
<td> $".$Duty."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Handling Fee: </td>
<td> $".$Handling." </td>
</tr>
<tr class ='2ndtr' >
<td > Consolidation Fee: </td>
<td> $".$Consolidation." </td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Delivery Fee: </td>
<td> $".$Delivery." </td>
</tr>
<tr class ='2ndtr' >
<td > <strong>Total Amount: </strong> </td>
<td><strong>$".$Amount."</strong> </td>
</tr>
</table>
<div>
<br><br>
Thanks for using our service! We appreciate it.
<br><br>
Regards,<br>
".$site_name."
<br>______________________________________________________<br><br>
<strong>Call Us</strong><br><br>
<strong>Rodney Bay</strong>: 458-9378 <strong>Castries</strong>: 451-9378 <strong>Vieux Fort</strong>: 454-9378
</div>
";
$messageinvadmin .=
" <style>
#media screen (max-width:768px) { /* smartphones, iPhone, portrait 480x320 phones */
#packagetable{
margin-left:20px;
}
}
</style>
<div><strong>".$Name."</strong> with email address ".$userdata->data->user_email.", had an invoice update. <br><br>
View the changes below
</div>
<br><br>
<table id='packagetable' style='border:1px solid #8EAADB; margin-left:150px;'>
<tr class ='invhead' style='background-color:#4472C4; color:white;'>
<th>Charges</th>
<th>Amount (EC)</th>
</tr>
<tr class ='2ndtr' >
<td > Tracking Number </td>
<td> ".$trackingnumber."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Shipping Charge: </td>
<td> $".$Freight." </td>
</tr>
<tr class ='2ndtr' >
<td > Duty Charge: </td>
<td> $".$Duty."</td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Handling Fee: </td>
<td> $".$Handling." </td>
</tr>
<tr class ='2ndtr' >
<td > Consolidation Fee: </td>
<td> $".$Consolidation." </td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Delivery Fee: </td>
<td> $".$Delivery." </td>
</tr>
<tr class ='2ndtr' >
<td > <strong>Total Amount: </strong> </td>
<td><strong>$".$Amount."</strong> </td>
</tr>
<tr class ='1str' style='background-color:#D9E2F3; '>
<td > Delivery Fee: </td>
<td> $".$Delivery." </td>
</tr>
</table>
_______________________________________________________
<br><br>
";
$closing = "Regards,<br>
".$site_name."
<br>______________________________________________________<br><br>
<strong>Call Us</strong><br><br>
<strong>Rodney Bay</strong>: 458-9378 <strong>Castries</strong>: 451-9378 <strong>Vieux Fort</strong>: 454-9378
</div>
";
$invtotalsql = mysql_fetch_assoc(mysql_query("SELECT invoice_total_charges FROM wp_xq4w067xaq_customer_invoice WHERE invoice_tracking_number = '$trackingnumber'"));
$packstatsql = mysql_fetch_assoc(mysql_query("SELECT pms_status FROM wp_xq4w067xaq_package WHERE tracking_id = '$trackingnumber'"));
if($Statuscsv == "Collected & Paid"){
$Statuscsv = 5;
}if($Statuscsv == "Available for Pick-Up"){
$Statuscsv = 4;
}if($Statuscsv == "Pending Invoice"){
$Statuscsv = 3;
}if($Statuscsv == "Paid"){
$Statuscsv = 7;
}if($Statuscsv == "Collected"){
$Statuscsv = 9;
}if($Statuscsv == "Shipped"){
$Statuscsv = 2;
}if($Statuscsv == "Received"){
$Statuscsv = 1;
}
if($invtotalsql['invoice_total_charges'] !== $Amount OR $packstatsql['pms_status'] !== $Statuscsv){
send_email_pkg2($userdata->data->user_email, $messageinv, $site_name. ' Package Amount Update',$userdata->user_email_2,$userdata->user_email_3);
//send_email_pkg("shipping#westtg.com", $messageinvadmin, $site_name. "Package Amount update");
//send_email_pkg("5sp4lr9#gmail.com", $messageinvadmin, $site_name. "Invoices");
//send_email_pkg("5sp4lr9#gmail.com", $message3, $site_name. "Minimum Invoices");
}
$sql = "UPDATE wp_xq4w067xaq_package SET pms_full_name='$Name',pms_status='$Statuscsv',pms_amount_owned='$Amount',pms_pickup='$Pickup' WHERE tracking_id='$trackingnumber'";
mysql_query($sql);
$c = $c + 1; // count number of package info updated
$sql2 = "UPDATE wp_xq4w067xaq_customer_invoice SET invoice_shipping_charge='$Freight',invoice_handling_fee='$Handling',invoice_consolidation_fee='$Consolidation',invoice_duty_charge='$Duty',invoice_added_tax='$Vtax',invoice_delivery_fee='$Delivery',invoice_insurance='$Insurance',invoice_total_charges='$Amount' WHERE invoice_tracking_number='$trackingnumber'";
mysql_query($sql2);
$c2 = $c2 + 1; // count number of invoices updated
//update_invoice2();
}
$finaladmin = $messageinvadmin.$closing;
send_email_pkg("shipping#westtg.com", $finaladmin, $site_name. "Package Amount update");
// Success OR Error Message
if($sql AND $sql2){
echo "Your database has imported successfully. You have inserted ". $c ." records in packages and ".$c2." records in invoices";
}else{
echo "Sorry! There is some problem.";
}
}

Related

PHP - Incorrect formatting

I am currently working through a PHP textbook to create a movie review website, however, the format of the page I have created is incorrect and I can't see the difference between my code and the code in the textbook. Here is a screenshot of the page I have created:
http://imgur.com/a/EBNxk
"Date" is supposed to be a table header alongside "Reviewer", "Comments" and "Rating". The "Reviews" header is also meant to be below the movie details and above "Date", "Reviewer", "Comment", and "Rating". The full code of the page is included below, I know the problem is probably going to be between the html tags but I'll include it all just incase.
EDIT: I see now that I left a quote mark out on line 130. Fixing this puts "Date" along with the other headers as it should be. But the Reviews header is still above the movie details.
<?php
function get_director($director_id)
{
global $db;
$query = "SELECT people_fullname FROM people WHERE people_id = ". $director_id;
$result = mysqli_query($db,$query) or die(mysqli_error($db));
$row = mysqli_fetch_assoc($result);
extract($row);
return $people_fullname;
}
function get_leadactor($leadactor_id)
{
global $db;
$query = "SELECT people_fullname FROM people WHERE people_id = ". $leadactor_id;
$result = mysqli_query($db,$query) or die(mysqli_error($db));
$row = mysqli_fetch_assoc($result);
extract($row);
return $people_fullname;
}
function get_movietype($type_id)
{
global $db;
$query = "SELECT movietype_label FROM movietype WHERE movietype_id = ". $type_id;
$result = mysqli_query($db,$query) or die(mysqli_error($db));
$row = mysqli_fetch_assoc($result);
extract($row);
return $movietype_label;
}
function generate_stars($rating)
{
$stars = " ";
for($i = 0; $i <= $rating; $i++)
{
$stars.= '<img src = "star.png" alt = "star " />';
}
return $stars;
}
function calculate_difference($takings,$cost)
{
$difference = $takings - $cost;
if($difference<0)
{
$color = "red";
$difference = "$ ".abs($difference)." million";
}
else if ($difference > 0)
{
$color = "green";
$difference = "$ ".abs($difference)." million";
}
else
{
$color = "blue";
$difference = "$ ".abs($difference)." million";
}
return "<span style = \"color:".$color.";\">".$difference."</span>";
}
$db = mysqli_connect('localhost','root') or die('Unable to connect');
mysqli_select_db($db,'moviesite') or die (mysqli_error($db));
$query = "SELECT movie_name, movie_year, movie_director, movie_leadactor,
movie_type, movie_running_time, movie_cost, movie_takings
FROM movie
WHERE movie_id = ".$_GET["movie_id"];
$result = mysqli_query($db,$query);
$row = mysqli_fetch_assoc($result);
$movie_name = $row['movie_name'];
$movie_director = get_director($row['movie_director']);
$movie_leadactor = get_leadactor($row['movie_leadactor']);
$movie_year = $row['movie_year'];
$movie_running_time = $row['movie_running_time']." mins";
$movie_takings = $row['movie_takings']." million";
$movie_cost = $row['movie_cost']." million";
$movie_health = calculate_difference($row['movie_takings'],$row['movie_cost']);
echo <<<ENDHTML
<html>
<head>
<title> Details for $movie_name </title>
</head>
<body>
<div style = "text-align:center">
<h2> $movie_name </h2>
<h3> Details </h3>
<table cellpadding = "2" cellspacing = "2" style = "width:70%; margin-left:auto; margin-right:auto">
<tr>
<td> <strong> Title </strong></td>
<td> $movie_name </td>
<td> <strong> Release Year </strong></td>
<td> $movie_year </td>
</tr>
<tr>
<td> <strong> Movie Director </strong></td>
<td> $movie_director </td>
<td> <strong> Cost </strong></td>
<td> $movie_cost </td>
</tr>
<tr>
<td> <strong> Lead Actor </strong></td>
<td> $movie_leadactor </td>
<td> <strong> Takings </strong></td>
<td> $movie_takings </td>
</tr>
<tr>
<td> <strong> Running Time </strong></td>
<td> $movie_running_time </td>
<td> <strong> Health </strong></td>
<td> $movie_health </td>
</tr>
ENDHTML;
$query = 'SELECT review_movie_id, review_date, reviewer_name, review_comment, review_rating
FROM reviews
WHERE review_movie_id = '.$_GET['movie_id'] . '
ORDER BY review_date DESC';
$result = mysqli_query($db, $query) or die(mysqli_error($db));
echo <<<ENDHTML
<h3><em>Reviews</em></h3>
<table cellpadding = "2" cellspacing = "2"
style = "width:90%; margin-left:auto; margin-right:auto;>
<tr>
<th style = "width: 7em"> Date </th>
<th style = "width: 10em"> Reviewer </th>
<th> Comments </th>
<th style = "width: 5em"> Rating </th>
</tr>
</table>
ENDHTML;
while($row = mysqli_fetch_assoc($result))
{
$date = $row['review_date'];
$name = $row['reviewer_name'];
$comment = $row['review_comment'];
$rating = generate_stars($row['review_rating']);
echo <<<ENDHTML
<td style = "vertical-align: top; text-align:center"> $date </td>
<td style = "vertical-align: top; text-align:center"> $name </td>
<td style = "vertical-align: top; text-align:center"> $comment </td>
<td style = "vertical-align: top; text-align:center"> $rating </td>
<br/>
ENDHTML;
}
echo <<< ENDHTML
</div>
</body>
</html>
ENDHTML;
?>
Try closing the quote marks on style:
<table cellpadding = "2" cellspacing = "2" style = "width:90%; margin-left:auto; margin-right:auto;">
<tr>
<th style = "width: 7em"> Date </th>

Broken PHP page

I am trying to access this weapon store file and am getting a blank page. I was hoping someone could help me fix this. The link.php file is just a page holding images and is not the source of the problem as other pages calling on link work fine.
<?php
echo "<table width='100%'><tr><td valign='left' width='95%'><font size=2 color=silver><b>Weapon Market</b></font></td><td><table width=100%><tr><td align=right>";
include('../beta/files/link.php');
echo" Weapon Market. Users can come here to buy weapons that they can to to another city and sell at a black market for profit.'></a></td></tr></table><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br /><br />";
if(!isset($tools)){
echo"<font color=red><b>Error | It Seems Something Went Wrong Processing Your Account. Please Try Logging Out And Then Logging Back In. If The Problem Persists Please Email Support At Account#Steam-Wars.com. We Apologize For The Inconvenience.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
session_destroy();
exit();}
$qry = 'SELECT * FROM weapons WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$has_weapons_array = mysql_fetch_array($res);
$weapon_names = array('bbgun_bullet', 'handgun_bullet', 'shotgun_bullet', 'rifle_bullet', 'bbgun', 'handgun', 'shotgun', 'ak47', 'bomb', 'taser', 'baseballbat', 'shank', 'detonator', 'battery');
$name_hash = array(
'bbgun_bullet' => 'BBGun Bullet (4-9)',
'handgun_bullet' => 'Handgun Bullet (9-47)',
'shotgun_bullet' => 'Shotgun Bullet (28,142)',
'rifle_bullet' => 'Rifle Bullet (47-237)',
'bbgun' => 'BBGun (280-300)',
'handgun' => 'Handgun (470-500)',
'shotgun' => 'Shotgun (96-100)',
'ak47' => 'AK47 (415-500)',
'bomb' => 'Bomb (248-250)',
'taser' => 'Taser (45-50)',
'baseballbat' => 'Baseball Bat (90-100)',
'shank' => 'Shank (55-100)',
'detonator' => 'Detonator (427-475)',
'battery' => 'Battery (3-9)'
);
$qry = 'SELECT * FROM prices_booze WHERE city='.db_quote_smart($player->city);
$res = db_query($qry);
$prices = mysql_fetch_array($res);
$qry = 'SELECT * FROM weapons WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$weapons = mysql_fetch_array($res);
$limit = $has_weapons_array["weapon_limit"];
$space_used = 0;
foreach($weapon_names as $name){
$space_used += $weapons[$name];
}
$space_left = $limit - $space_used;
$action = $_GVARS['action'];
if( $action == 'buy' ){
foreach($weapon_names as $weapon){
$price = $prices[$weapon];
$amount = (isset($_POST[$weapon]) ? intval($_POST[$weapon]) : 0);
$cost = $price * $amount;
if( $amount > 0 ){
if( $gUser['cash'] < $cost ){
echo"<font color=red><b>Error | You Do Not Have Enough Money To Purchase $amount unit(s) Of $weapon.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
}elseif( ($space_left-$amount) < 0 ){
echo"<font color=red><b>Error | You Do Not Have Enough Space To Carry $amount unit(s) Of $weapon.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
}else{
$space_left -= $amount;
$gUser['cash'] -= $cost;
$qry = 'UPDATE user_characters SET cash=cash-'.$cost.' WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$randscam = mt_rand(1, 100);
$randscam2 = mt_rand(1, 100);
if( $randscam == $randscam2 ){
echo"<font color=red><b>Error | You Were Scammed By A Dealer. The Weapons You Bought Turned Out To Be Replicas.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
$randexp=rand(0,1);
$qry = 'UPDATE user_characters SET exp=exp+'.$randexp.', drug_points=drug_points+'.$amount.' WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
}else{
$qry = "UPDATE weapons SET $weapon=$weapon+$amount WHERE uid=".db_quote_smart($player->uid);
$res = db_query($qry);
$randexp2=rand(1,2);
$qry = 'UPDATE user_characters SET exp=exp+'.$randexp2.', drug_points=drug_points+'.$amount.' WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$sql="UPDATE adv_stats SET drugs_bought=drugs_bought+$amount WHERE uid=".db_quote_smart($player->uid);
$sql=mysql_query($sql);
echo"<font color=green><b>Ciao | You Have Purchased $amount Crate(s) Of $weapon.</b></font><br /><br /><center><img src='/beta/layout_images/headertop.gif' width=100% height=4></center><br />";
}
}
}
}
}
// gets updated version of weapons in pocket
$qry = 'SELECT * FROM weapons WHERE uid='.db_quote_smart($player->uid);
$res = db_query($qry);
$has_weapons_array = mysql_fetch_array($res);
echo "<table align=center width=100% bgcolor=000000><tr><td><br>";
echo "<table width='450' cellpadding='0' border='2' bordercolor='black' style='margin:0 auto;background-image: url(/beta/layout_images/bg_2.gif);'>
<tr bgcolor=#11111>
<td align=center>
<font face=verdana size=1 color=silver><b>Weapon</b></font>
</td>
<td align=center>
<font face=verdana size=1 color=silver><b>Cost</b></font>
</td>
<td align=center>
<font face=verdana size=1 color=silver><b># you have</b></font>
</td>
<td align=center>
<font face=verdana size=1 color=silver><b># to buy</b></font>
</td>
</tr>";
$space_used = 0;
$row = 0;
foreach($weapon_names as $weapon){
$space_used += $has_weapons_array[$weapon];
echo('<tr bgcolor="#'.($row++ % 2 ? '444444' : '333333').'">
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><b>'.$name_hash[$weapon].'</b></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">$ '.number_format($prices[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">'.number_format($has_weapons_array[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><form name="login" action="driver.php?x=weaponstore" method="post"><input type="text" name="'.$weapon.'" size=5 style="font-weight:none;font-size:8pt;color:#ffffff;font-family:arial;background-color:#000000;border-color:#ffffff" maxlength="15"></font></td>
</tr>');
echo "
</table>
<table width='450' cellpadding='0' border='2' bordercolor='black' style='margin:0 auto;background-image: url(/beta/layout_images/bg_2.gif);'>
<tr bgcolor=#11111 valign=top><td>
<table width=100%><tr>
<td align=left width=125><font face=verdana size=1 color=silver><input type=radio checked name=action value=buy> Buy </td>
<td align=center width=250><font size=1><font color=#FFFFFF><b>Weapon space:</b></font> " . $space_used . "/" . $has_weapons_array["weapon_limit"] . "</font></td>
<td align=right width=125><center><font face=verdana size=1 color=silver><input type=submit value=\" Purchase Weapon \" style=\"FONT-WEIGHT: bold; FONT-SIZE: 8pt; COLOR: #FFFFFF; FONT-FAMILY: Arial; BACKGROUND-COLOR: #333333\" size=1></center></td>
</tr></table>
</td></tr>
</table>";
?>
This question was answered by me and you deleted it...
As I said before there is no end bracket in last foreach !
foreach($weapon_names as $weapon){
$space_used += $has_weapons_array[$weapon];
echo('<tr bgcolor="#'.($row++ % 2 ? '444444' : '333333').'">
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><b>'.$name_hash[$weapon].'</b></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">$ '.number_format($prices[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff">'.number_format($has_weapons_array[$weapon]).'</font></td>
<td align="center" width="125"><font face="tahoma" size="1" color="#ffffff"><form name="login" action="driver.php?x=weaponstore" method="post"><input type="text" name="'.$weapon.'" size=5 style="font-weight:none;font-size:8pt;color:#ffffff;font-family:arial;background-color:#000000;border-color:#ffffff" maxlength="15"></font></td>
</tr>');
}

how to give color to table tr?

Hello i have a table with some fields like
here i want make colors for table entire rows..means if ASR value is 75 to 100 should get one color and 50 to 75 should get another color and below 50 should get another color.
and here is my php code
<table width="75%" border="1">
<tr>
<td align="center">channel no</td>
<td align="center">IP</td>
<td align="center">Total calls</td>
<td align="center">Connected calls</td>
<td align="center">Disconnected calls</td>
<td align="center">Duration</td>
<td align="center">ASR</td>
<td align="center">ACD</td>
</tr>
<?php
while ($row = mysql_fetch_assoc($result)) {
//$minutes = gmdate("H:i:s", $row['tduration']);
echo "<tr>
<td>".$row['channel']." </td>
<td>".$row['ip']." </td>
<td>".$row['totalcalls']." </td>";
if ($row['totalcalls']>1){
$sql1 = "SELECT count(duration) as count FROM gateways where duration=0 and ip='".$_POST['ip']."' and channel='".$row['channel']. "' and (connect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' or disconnect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' ) Group by channel";
$result1 = mysql_query($sql1, $link);
$norow=mysql_fetch_assoc($result1);
$attenedcalls=($row['totalcalls']-$norow['count']);
echo "<td>".$attenedcalls." </td>";
$disconnectedcalls=($row['totalcalls']-$attenedcalls);
echo "<td>".$disconnectedcalls." </td>";
echo " <td>".$row['tduration']." </td>";
echo "<td>".(($attenedcalls/$row['totalcalls'])*100)."</td>";
}else{
echo "<td>".$row['totalcalls']."</td>";
echo "<td>100</td>";
}
$minutes = gmdate("H:i:s", ($row['tduration']/$attenedcalls));
echo " <td>".$minutes." </td>
</tr>";
}
?>
</table>
thanks in advance
You can try like this
<table width="75%" border="1">
<tr>
<td align="center">channel no</td>
<td align="center">IP</td>
<td align="center">Total calls</td>
<td align="center">Connected calls</td>
<td align="center">Disconnected calls</td>
<td align="center">Duration</td>
<td align="center">ASR</td>
<td align="center">ACD</td>
</tr>
<?php
while ($row = mysql_fetch_assoc($result)) {
$color = '';
if ($row['totalcalls']>1){
$sql1 = "SELECT count(duration) as count FROM gateways where duration=0 and ip='".$_POST['ip']."' and channel='".$row['channel']. "' and (connect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' or disconnect_datetime BETWEEN ' ".$_POST['toval']." ' and '".$_POST['fromval']."' ) Group by channel";
$result1 = mysql_query($sql1, $link);
$norow=mysql_fetch_assoc($result1);
$attenedcalls=($row['totalcalls']-$norow['count']);
$asr = (($attenedcalls/$row['totalcalls'])*100);
if($asr >= 75 && $asr <=100 ){
$color = 'red';
}else if($asr >= 50 && $asr < 75){
$color = 'cyan';
}else if($asr < 50){
$color = 'blue';
}
}
//$minutes = gmdate("H:i:s", $row['tduration']);
echo "<tr style='background-color : ".$color."'>
<td>".$row['channel']." </td>
<td>".$row['ip']." </td>
<td>".$row['totalcalls']." </td>";
if ($row['totalcalls']>1){
echo "<td>".$attenedcalls." </td>";
$disconnectedcalls=($row['totalcalls']-$attenedcalls);
echo "<td>".$disconnectedcalls." </td>";
echo " <td>".$row['tduration']." </td>";
echo "<td>".$asr."</td>";
}else{
echo "<td>".$row['totalcalls']."</td>";
echo "<td>100</td>";
}
$minutes = gmdate("H:i:s", ($row['tduration']/$attenedcalls));
echo " <td>".$minutes." </td>
</tr>";
}
?>
</table>
[...]
while ($row = mysql_fetch_assoc($result)) {
$asrVal=(($attenedcalls/$row['totalcalls'])*100);
if($asrVal>=50 && $asrVal <=75) $class="from50to75";
if($asrVal>=75 && $asrVal <=100) $class="from75to100";
if($asrVal<50) $class="below50";
//$minutes = gmdate("H:i:s", $row['tduration']);
echo "<tr class='$class'>
[...]
then add:
<style>
tr.from50to75 td{background-color:red;}
tr.from75to100 td{background-color:green;}
tr.below50 td{background-color:blue;}
</style>
Modify your while loop so that you compute the ASR value before emitting the <tr> tag. Use that value to select a class according to the classification you have set up, and emit a tag of the form <tr class=foo> where foo is the class name you have selected. Then it’s just a matter of writing CSS rules for the classes, using class selectors like tr.foo.
(Provided that you have not set color on the td cells. If you have, you need to use selectors like tr.foo td to override such settings.)

PHP displaying individual tables

At the moment my produces results from a database and then inserts all of the results into one HTML table.
Is there any way that it would be possible so that for each result returned it created an individual HTML table (opposed to all of the results going into one HTML table)
My code:
<table class=\"board\" width='100%' border='0' align='center' cellpadding='1' cellspacing='1'>
");
$type = $_GET["type"];
if ($type == "" || $type == "request") {
$get = mysql_query("SELECT * FROM request WHERE type='Request' AND deleted != 'yes' ORDER BY id DESC");
} else {
if ($type == "shoutout") {
$get = mysql_query("SELECT * FROM request WHERE type='Shoutout' AND deleted != 'yes' ORDER BY id DESC");
} else {
if ($type == "competition") {
$get = mysql_query("SELECT * FROM request WHERE type='Competition' AND deleted != 'yes' ORDER BY id DESC");
} else {
if($type == "all") {
$get = mysql_query("SELECT * FROM request WHERE deleted != 'yes' ORDER BY id DESC");
}
}
}
}
$num = #mysql_num_rows($get);
if ($num == 0) {
echo ("<div class=\"board\"><center><font color=\"red\">There aren't any requests in this category!<br />
Why not ask listeners to send in their requests?</font></center></div>");
} else {
while ($r = mysql_fetch_array($get)) {
echo "
<tr>
<td><font face=\"verdana\" size=\"1\"><b>User</b></td>
<td><font face=\"verdana\" size=\"1\"><b>$r[habboname]</b></td>
</tr>
<tr>
<td><font face=\"verdana\" size=\"1\"><b>Date</b></td>
<td><font face=\"verdana\" size=\"1\">$r[date]</td>
</tr>
<tr>
<td><font face=\"verdana\" size=\"1\"><b>IP</b></td>
<td><font face=\"verdana\" size=\"1\">$r[ip]</td>
</tr>
<tr>
<td><font face=\"verdana\" size=\"1\"><b>Message</b></td>
<td><font face=\"verdana\" size=\"1\">$r[message]</td>
</tr>
<tr>
<td><font face=\"verdana\" size=\"1\"><b>Type</b></td>
<td><font face=\"verdana\" size=\"1\">$r[type]</td>
</tr>
<tr>
<!-- <td><font face=\"verdana\" size=\"1\"><b>Refferer</b></td>
<td><font face=\"verdana\" size=\"1\">";
if($r[refferer] == 1){ echo "Site.com</td>"; } else { echo "Site1.com</td>"; }
echo "--></tr>
<tr>
<td><font face=\"verdana\" size=\"1\"><b>Commands</b></td>
<td><font face=\"verdana\" size=\"1\">Delete - Ban - <!--Alert-->Nominate LoTW</font></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
";
$id = htmlspecialchars($_GET['id']);
$delete = mysql_query("UPDATE request SET deleted = 'yes' WHERE id = '$id'");
}
echo ("</table></div>");
}
break;
case 'delete':
If you mean to create as many tables as there are returned rows, just put the opening <table> into the while's beginning and the closing </table> to the end of while. However, I don't understand why this would be desired. Do you really want to create many tables with just one row? It kind of defeats the purpose of a table. Make a list or use span's or anything else than tables instead.
while ($r = mysql_fetch_array($get)) {
echo "<table class=\"board\">
<tr>
<td><b>User</b></td>
<td><b>$r[habboname]</b></td>
</tr>
<tr>
<td><b>Date</b></td>
<td>$r[date]</td>
</tr>
<tr>
<td><b>IP</b></td>
<td>$r[ip]</td>
</tr>
<tr>
<td><b>Message</b></td>
<td>$r[message]</td>
</tr>
<tr>
<td><b>Type</b></td>
<td>$r[type]</td>
</tr>
<tr>
<!-- <td><b>Refferer</b></td>
<td>";
if($r[refferer] == 1){ echo "Site.com</td>"; } else { echo "Site1.com</td>"; }
echo "--></tr>
<tr>
<td><b>Commands</b></td>
<td>Delete - Ban - <!--Alert-->Nominate LoTW</font></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>";
$id = htmlspecialchars($_GET['id']);
$delete = mysql_query("UPDATE request SET deleted = 'yes' WHERE id = '$id'");
}
echo "</div>"; //remove () after echo
Update. One another thing. Please don't use inline styling. You have table class="board" so you already probably know the power of CSS.
Second update. I removed <font ...> tags. Use CSS for example like this:
table.board{
width:100%;
border:0;
align:center;
cellpadding:1;
cellspacing:1;
}
table.board td{
font-family: Verdana, Geneva, Arial, sans-serif;
font-size: 1em;
}
CSS saves a lot of trouble when you want to change styling. And trust me, there will be a time when you want to change it (or your boss want's to bling-bling the site...).
ZZ-bb is absolutely right and as a hint try to put if/else construction in mysql - it will move faster or optimize it in php, like:
$get = mysql_query("SELECT * FROM request WHERE " . ($type == 'all' ? 'type = 1' : 'type = ucfirst($type)' ) . " AND deleted != 'yes' ORDER BY id DESC");

SQL database interaction

I am making a database, which will interact with a SQL table.
What I have achieved so far:
Add rows to the table.
Delete rows from the table.
Search rows from the table.
Paginate the results.
What I need to achieve:
A log in prompt when a guest tries to
access the page.
In fact, I have successfully installed a log in script for it, but it seems to not work properly, here is the error:
Fatal error: Allowed memory size of
25165824 bytes exhausted (tried to
allocate 77824 bytes) in
/home/vol3/byethost12.com/b12_3598660/htdocs/coordbase/database.php on line 238
Now that I do not have permission to allow more memory from my host, I would need a way around this.
I have already tried separating the file into multiple pages, but it seems that it still tried to allocate the same amount of bytes.
Here is the file:
<?php
require_once('db.php'); // for database details
ini_set('display_errors',1);
error_reporting (E_ALL ^ E_NOTICE);
require('../include/session.php');
if (!$session->isMember())
{
header("../resources.php");
}
else
{
$self = $_SERVER['PHP_SELF']; //the $self variable equals this file
$ipaddress = ("$_SERVER[REMOTE_ADDR]"); //the $ipaddress var equals users IP
$connect = mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>');
mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>');
require('../include/header.php');//Page Header
if($_GET['cmd'] == "delete")
{
echo "<center><h1>Delete</h1></center>";
if(isset($_POST['delete'])) {
$time = date("Y-m-d H:i:s");
$queryc = "DELETE FROM coords WHERE id=".$_GET['id'].";";
$resultc = mysql_unbuffered_query("$queryc") or die("Could not delete the selected base from the database at this time, please try again later.");
$sqls = "INSERT INTO reports SET ip='$ipaddress', date='$time';";
//run the query. if it fails, display error
$report = mysql_unbuffered_query("$sqls") or die("Could not add report to the database, but the base has been deleted successfully.");
echo "<center>The selected base has been deleted from the database successfully!<br>
<a href=http://www.teamdelta.byethost12.com/coordbase/database.php>Back to Main</a><br><br>
<font color=\"red\"><b>YOUR IP HAS BEEN LOGGED. ABUSE OF THIS SYSTEM WILL RESULT IN AN IP BAN!</b></font></center>";
}
else
{
$queryd = "SELECT * FROM coords WHERE id=".$_GET['id'].";";
$resultf = mysql_unbuffered_query("$queryd") or die('<p class="error">There was an unexpected error grabbing the base from the database.</p>');
?>
<center>
<table>
<table width="83%" border="1">
<tr>
<td ><b>Tag</b></td>
<td ><b>Guild</b></td>
<td ><b>Player</b></td>
<td ><b>Base</b></td>
<td ><b>Location</b></td>
<td ><b>Econ</b></td>
<td ><b>Comments</b></td>
</tr>
<?php
while ($rowa = mysql_fetch_array($resultf)) {
$id = stripslashes($rowa['id']);
$tag = stripslashes($rowa['tag']);
$guild = stripslashes($rowa['guild']);
$name = stripslashes($rowa['name']);
$base = stripslashes($rowa['base']);
$location = stripslashes($rowa['location']);
$comment = stripslashes($rowa['comment']);
$id = stripslashes($rowa['id']);
$econ = stripslashes($rowa['econ']);
$maxecon = stripslashes($rowa['maxecon']);
echo('<tr><center><td>['.$tag.']</td><td>'.$guild.'</td><td>'.$name.'</td><td>'.$base.'</td><td>'.$location.'</td><td>'.$econ.'/'.$maxecon.'</td><td>'.$comment.'</td></center></tr>');
}
?>
</table>
</table>
<b>Are you sure you wish to delete the selected base?</b>
<br>
<input type="button" value="Cancel" id="button1" name="button1"onclick="window.location.href='database.php';">
<form action="<?php $self ?>" name="deletefrm" method="post" align="right" valign="bottom" onsubmit="return validate();">
Confirm Delete<input type=checkbox name="confirm"><input type="submit" name="delete" value="Delete" />
</form>
</center>
<br>
<center><font color="red"><b>YOUR IP WILL BE LOGGED. ABUSE OF THIS SYSTEM WILL RESULT IN AN IP BAN!</b></font></center>
<?php
}
}
else
{
if(isset($_POST['add'])) {
?>
<tr>
<td style="background: url(http://www.teamdelta.byethost12.com/barbg.jpg) repeat-x top;">
<center><b><font color="#F3EC84">»Info«</font></b></center>
</td>
</tr>
<tr><!--info content-->
<td style="background: #222222;">
<?php
//fetch data
$data = strip_tags(mysql_real_escape_string($_POST['list']));
$comment = strip_tags(mysql_real_escape_string($_POST['comment']));
$data_lines = explode( "\\r\\n", $data );
$comment_lines = explode("\\r\\n", $comment);
for($i=0;$i<count($data_lines);$i++)
{
$data_fields = explode( ",", $data_lines[$i]);
$time = time();
$queryb = "INSERT INTO coords SET
tag='{$data_fields[0]}',
guild='{$data_fields[1]}',
name='{$data_fields[2]}',
base='{$data_fields[3]}',
econ='{$data_fields[5]}',
maxecon='{$data_fields[6]}',
location='{$data_fields[4]}',
comment='{$comment_lines[$i]}',
ipaddress='$ipaddress' ,
date='$time';";
// if it succeeds, display message
if (mysql_unbuffered_query($queryb))
{
echo('<p class="success">Successful posting of ['.$data_fields[3].']!</p>');
}
else
{
echo('<p class="error">Error could not post ['.$data_fields[3].'] to database!</p>');
}
}//end for loop
}//end if $_POST['add'] statement
?>
<?php
if (isset($_GET['cmd']) == "add"){
?>
<!--start inputbox-->
<center><table width="100%">
<tr>
<td style="background: url(http://www.teamdelta.byethost12.com/barbg.jpg) repeat-x top;">
<center><b><font color="#F3EC84">»Add«</font></b></center>
</td>
</tr>
<tr>
<td style="background: #222222;"><!-- at the bottom of the page, we display our comment form -->
<form action="<?php $self ?>" method="post" onsubmit="return valid(this)">
<table width="100%" border ="0" valign="top">
<tr>
<td>
List:
</td>
<td align="left">
<textarea name="list" rows="10" cols="70"></textarea>
</td>
<td valign="top">
<font color="red"><b>[Post list arranged like so!]</b></font><br>
<br>
E.G:<br>
<br>
(tag),(guild),(player,(base),(coordinates),(econ),(maxecon)<br>
~TD~,~Team Delta~,DarkLink,Base1,D03:56:21:11,101,101<br>
FARM,Guild896,player 5,Base #3,D69:62:89:10,98,135<br>
</td>
</tr>
</tr>
<td>
Comment:
</td>
<td>
<textarea name="comment" rows="10" cols="70"></textarea>
</td>
<td>
<font color="red"><b>[Post comments on a new line for each base!]</b></font><br>
E.G "PS 10/10 PR 10/10"<br>
"PR 5/5 DT 10/10"
</td>
<td>
<td>
</td>
<td valign="bottom" align="right">
<p>
<input type="submit" name="add" value="Add" />
</p>
</td>
</tr>
</table>
</form>
Back to Main
</td>
</tr>
</table></center>
<!--end input box-->
<?php
}
else
{
if (isset($_GET['search']) == "do"){
$title = "<center><h1>Results</h1>";
$search = stripslashes($_GET['searchterm']);
$asearch = trim($search);
$bsearch = strip_tags($asearch);
$csearch = mysql_real_escape_string($bsearch);
$types = "types of search";
switch ($_GET['type']){
case 'name':
$types = "name";
break;
case 'tag':
$types = "tag";
break;
case 'guild':
$types = "guild";
break;
default:
$types = "";
echo "<center><b>Please select a search type before continuing! You are being redirected, please wait.<br>
Click here, if you do not wish to wait.</b></center>";
header("Refresh: 5; url=http://www.teamdelta.byethost12.com/coordbase/database.php");
exit;
break;
}
$querya = "SELECT * FROM coords WHERE `{$types}` LIKE '%{$csearch}%' ORDER BY `{$types}`;";
$result = mysql_unbuffered_query("$querya") or die("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$querya}");
if (mysql_num_rows($result) < 1) {
echo $title;
echo "<b><center>We are sorry to announce that the search term provided: \"{$search}\", yielded no results. <br>"
."<hr>"
."New Search</center></b>";
exit;
}else {
echo $title;
?>
<b>for "<?php echo $search;?>".</b>
<hr>
<table>
<table width="83%" border="1">
<tr>
<td ><b>Tag</b></td>
<td ><b>Guild</b></td>
<td ><b>Player</b></td>
<td ><b>Base</b></td>
<td ><b>Location</b></td>
<td ><b>Econ</b></td>
<td ><b>Comments</b></td>
<td ><b>Delete</b></td>
</tr>
<?php
while ($row = mysql_fetch_array($result)) {
$id = stripslashes($row['id']);
$tag = stripslashes($row['tag']);
$guild = stripslashes($row['guild']);
$name = stripslashes($row['name']);
$base = stripslashes($row['base']);
$location = stripslashes($row['location']);
$comment = stripslashes($row['comment']);
$id = stripslashes($row['id']);
$econ = stripslashes($row['econ']);
$maxecon = stripslashes($row['maxecon']);
echo('<tr><center><td>['.$tag.']</td><td>'.$guild.'</td><td>'.$name.'</td><td>'.$base.'</td><td>'.$location.'</td><td>'.$econ.'/'.$maxecon.'</td><td>'.$comment.'</td><td><a href=database.php?id='.$id.'&cmd=delete>Delete</a></td></center></tr>');
}
echo "New Search";
?>
</table>
</table>
<?php
}
}
else{
// find out how many rows are in the table
$sql = "SELECT COUNT(*) FROM coords";
$result = mysql_unbuffered_query($sql, $connect) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];
// number of rows to show per page
$rowsperpage = 10;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);
// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
// cast var as int
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
} // end if
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if
// the offset of the list, based on current page
$offset = ($currentpage - 1) * $rowsperpage;
?>
</center>
<!--start inputbox-->
<center>
<table width="83%">
<tr>
<td style="background: url(http://www.teamdelta.byethost12.com/barbg.jpg) repeat-x top;">
<center><b><font color="#F3EC84">»Search«</font></b></center>
</td>
</tr>
<tr>
<td style="background: #222222;"><!-- at the bottom of the page, we display our comment form -->
<form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm" onsubmit="return valid(this)">
<table border ="0" width="100%">
<tr>
<td><center>
Search For: <input type="text" name="searchterm">
Player <input type="radio" name="type" value="name" checked> |
Guild Tag <input type="radio" name="type" value="tag"> |
Guild Name <input type="radio" name="type" value="guild">
<input type="hidden" name="search" value="do">
<input type="submit" value="Search">
Add new bases
</tr>
</center>
</td>
</tr>
</form>
</td>
</tr>
</table>
</center>
<!--end input box-->
<hr>
<center>
<table>
<table width="83%" border="1">
<tr>
<td ><b>Tag</b></td>
<td ><b>Guild</b></td>
<td ><b>Player</b></td>
<td ><b>Base</b></td>
<td ><b>Location</b></td>
<td ><b>Econ</b></td>
<td ><b>Comments</b></td>
<td ><b>Delete</b></td>
</tr>
<?php
$query = "SELECT * FROM coords ORDER BY `tag` ASC LIMIT $offset, $rowsperpage;";
$result = mysql_unbuffered_query("$query") or die('<p class="error">There was an unexpected error grabbing routes from the database.</p>');
// while we still have rows from the db, display them
while ($row = mysql_fetch_array($result)) {
$id = stripslashes($row['id']);
$tag = stripslashes($row['tag']);
$guild = stripslashes($row['guild']);
$name = stripslashes($row['name']);
$base = stripslashes($row['base']);
$location = stripslashes($row['location']);
$comment = stripslashes($row['comment']);
$id = stripslashes($row['id']);
$econ = stripslashes($row['econ']);
$maxecon = stripslashes($row['maxecon']);
echo('<tr><center><td>['.$tag.']</td><td>'.$guild.'</td><td>'.$name.'</td><td>'.$base.'</td><td>'.$location.'</td><td>'.$econ.'/'.$maxecon.'</td><td>'.$comment.'</td><td><a href=database.php?id='.$id.'&cmd=delete>Delete</a></td></center></tr>');
}
?>
</table>
</table>
<?php
/****** build the pagination links ******/
// range of num links to show
$range = 3;
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
// if we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " [<b>$x</b>] ";
// if not current page...
} else {
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
} // end else
} // end if
} // end for
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
// echo forward link for lastpage
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/
}//end else of search
}//end else of add
}//end else of delete
?>
</center>
<?php
require('../include/footer.php');//Page footer
}
?>
This would be around line 238:
<?php
//fetch data
$data = strip_tags(mysql_real_escape_string($_POST['list']));
$comment = strip_tags(mysql_real_escape_string($_POST['comment']));
$data_lines = explode( "\\r\\n", $data );
$comment_lines = explode("\\r\\n", $comment);
for($i=0;$i<count($data_lines);$i++)
{
$data_fields = explode( ",", $data_lines[$i]);
$time = time();
$queryb = "INSERT INTO coords SET
tag='{$data_fields[0]}',
guild='{$data_fields[1]}',
name='{$data_fields[2]}',
base='{$data_fields[3]}',
econ='{$data_fields[5]}',
maxecon='{$data_fields[6]}',
location='{$data_fields[4]}',
comment='{$comment_lines[$i]}',
ipaddress='$ipaddress' ,
date='$time';";
// if it succeeds, display message
if (mysql_unbuffered_query($queryb))
{
echo('<p class="success">Successful posting of ['.$data_fields[3].']!</p>');
}
else
{
echo('<p class="error">Error could not post ['.$data_fields[3].'] to database!</p>');
}
}//end for loop
}//end if $_POST['add'] statement
?>
I have noticed that the memory exceeds the limit when I include session.php to my file.
The problem is that I need that file for my log in prompt to work.
Check for recursions, this code cannot possibly exhaust memory. Try adding echo's around the code.

Categories