Jump to content

[SOLVED] 500 error - what the deuce?!?!?!


memphisweb

Recommended Posts

I'm getting a funky 500 error and am trying to track it down -- here is the code in question -- please help

I know I missed something simple and stupid --- possibly my query is all f'ed up

Thanks much

 

 

<? 
include "header.php"; 

$opco = $_POST['opco'];
$campaign = $_POST['campaign'];
$imagesize = $_POST['bannersize'];

$ad_id = $_POST['ad_id'];



// handles specific image size queries, DO NOT FUTZ WITH THIS CODE

if ( $imagesize == "bann1" ) {
$px = "10";
$py ="75";
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann2" ) {
$px = "108";
$py ="540";
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann3" ) {
$px = "120";
$py ="30";
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann4" ) {
$px = "120";
$py ="600";
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann5" ) {
$px = "160";
$py ="600";
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann6" ) {
$px = "180";
$py ="150";
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann7" ) {
$px = 210;
$py =800;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann8" ) {
$px = 215;
$py =35;
$sqlwidth="px=$px  AND py=$py";
}

//if ( $imagesize == "bann9" ) {
//$px = 230;
//$py =150;
//}

if ( $imagesize == "bann10" ) {
$px = 230;
$py =150;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann11" ) {
$px = 230;
$py =75;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann12" ) {
$px = 240;
$py =120;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann13" ) {
$px = 260;
$py =140;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann14" ) {
$px = 295;
$py =600;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann15" ) {
$px = 300;
$py =250;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann16" ) {
$px = 336;
$py =280;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann17" ) {
$px = 336;
$py = 850;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann18" ) {
$px = 425 ;
$py =600;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann19" ) {
$px = 450;
$py = 40;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann20" ) {
$px = 468;
$py = 60;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann21" ) {
$px = 512;
$py = 20;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann22" ) {
$px = 550;
$py = 480;
$sqlwidth="px=$px  AND py=$py";
}

if ( $imagesize == "bann23" ) {
$px = 720;
$py = 400;
$sqlwidth="px=$px  AND py=$py";
}
if ( $imagesize == "bann24" ) {
$px = 728;
$py = 90;
$sqlwidth="px=$px  AND py=$py";
}
if ( $imagesize == "bann25" ) {
$px = 728;
$py = 312;
$sqlwidth="px=$px  AND py=$py";
}
if ( $imagesize == "bann26" ) {
$px = 800;
$py = 600;
$sqlwidth="px=$px  AND py=$py";
}
if ( $imagesize == "bann27" ) {
$px = 900;
$py = 612;
$sqlwidth="px=$px  AND py=$py";

}

$sqlwidth="px=$px  AND py=$py";

/handles the variables for image size posting to display all images
if ( $imagesize == "0" ) {
$px = 0;
$py =0;
if ( $campaign > 0 ) {
$sqlcampaign="campaign_id=$campaign";
}

if ( $opco > 0 ) {
$sqlopco="AND company_id=$opco";
}
// figure out out to make this a selective mysql where image size is not a variable
$sqlcampaign= "
$bannersearchquery = "SELECT file_set.* FROM file_set  WHERE $sqlcampaign AND $sqlopco";


}

?>



<table width="800" cellpadding="0" cellspacing="0" border="0"  height="100%" >
  <tr> 
    <td width="151" valign="top" bgcolor="#660099"> 
      <? include "left_side_nav.php"; ?>
    </td>
    <td valign="top"> 

       <?







//$bannersearchquery = "SELECT file_set.* FROM file_set  WHERE $sqlwidth  $sqlcampaign $sqlopco";
$bannersearchquery = "SELECT file_set.* FROM file_set  WHERE $sqlcampaign AND $sqlopco";



$bannerresult = mysql_query ($bannersearchquery);
$bannernumrows=mysql_num_rows($bannerresult);


//if ($numrows == 0)
//  {
//  echo "<table width =\"100%\"><tr><td><h4>Sorry, no results were found</h4>";
//echo "</td></tr></table>";
//  } else {
//echo "<table width =\"100%\"><tr><td><h4>$numrows results were found</h4>";
//echo "</td></tr></table>";
//}


//$query2="SELECT name,company_id FROM campaign WHERE id=$campaign";
//$result2 = mysql_query ($query2);
//while($nt2=mysql_fetch_array($result2)){//Array or records stored in $nt
//$campaign_name = "$nt2[name]";
//$company_id = "$nt2[company_id]";
///* Option values are added by looping through the array */
//}

// $query3="SELECT name,id FROM company WHERE id=$company_id";
//$result3 = mysql_query ($query3);
//while($nt3=mysql_fetch_array($result3)){//Array or records stored in $nt
//$company_name = "$nt3[name]";
//$company_id2 = "$nt3[company_id]";
///* Option values are added by looping through the array */
//}



while($row = mysql_fetch_array( $result )) {

?>
<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="<? echo $row['px'];?>" height="<? echo $row['py'];?>" align="left">
<param name="movie" value="banners/<? echo $row['id'];?>.swf">
  <param name="quality" value="high">
  <embed src="banners/<? echo $row['id'];?>.swf" width="<? echo $row['px'];?>" height="<? echo $row['py'];?>" align="left" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>
</td></tr>
<tr>
          <td valign="top"> Campaign <? echo "$campaign_name";?>,Operating 
            Company : <? echo "$company_name";?> ,<br>
            <? echo $row['px'];?> width, <? echo $row['py'];?> height ,File Size 
            <? echo $row['fsize'];?>, Downloads: <? echo $row['dls'];?>, hits: 
            <? echo $row['hits'];?></td>

  </tr>
</table>
<hr noshade size="1">
 <?
 }
 ?>

  </form></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#660099"> </td>
    <td valign="top"> </td>
  </tr>
</table>

<? include "footer.php"; ?>

Link to comment
Share on other sites

Coupple errors found:

 

Line 174 should be:

//handles the variables for image size posting to display all images

Missing / at start of line

 

Line 186 - 189 should be:

// figure out out to make this a selective mysql where image size is not a variable
$bannersearchquery = "SELECT file_set.* FROM file_set  WHERE $sqlcampaign AND $sqlopco";

Line 187 needed deleting

Link to comment
Share on other sites

// figure out out to make this a selective mysql where image size is not a variable
$sqlcampaign= "
$bannersearchquery = "SELECT file_set.* FROM file_set  WHERE $sqlcampaign AND $sqlopco";

 

ALSO, not really a bug, but its just repetitive, you are setting the same variable in each of the ifs and then setting it again after the ifs... if you delete all the ones in the if statements it should minimize wasted code.

 

doh, wildteen beat me.

Link to comment
Share on other sites

ALSO, not really a bug, but its just repetitive, you are setting the same variable in each of the ifs and then setting it again after the ifs... if you delete all the ones in the if statements it should minimize wasted code.

 

doh, wildteen beat me.

Agreed. Those if statements would be better of it you stored each banner within an array, Like so:

//                bannx              px  py
$banners = array( 'bann1'  => array(10  , 75),
                  'bann2'  => array(108 , 540),
                  'bann3'  => array(120 , 30),
                  'bann4'  => array(120 , 600),
                  'bann5'  => array(160 , 600),
                  'bann6'  => array(180 , 150),
                  'bann7'  => array(210 , 800),
                  'bann8'  => array(215 , 35),
                  'bann9'  => array(230 , 100),
                  'bann10' => array(230 , 150),
                  'bann11' => array(230 , 75),
                  'bann12' => array(240 , 120),
                  'bann13' => array(260 , 140),
                  'bann14' => array(295 , 600),
                  'bann15' => array(300 , 250),
                  'bann16' => array(336 , 280),
                  'bann17' => array(336 , 850),
                  'bann18' => array(425 , 600),
                  'bann19' => array(450 , 40),
                  'bann20' => array(468 , 60),
                  'bann21' => array(512 , 20),
                  'bann22' => array(550 , 480),
                  'bann23' => array(720 , 400),
                  'bann24' => array(728 , 90),
                  'bann25' => array(728 , 312),
                  'bann26' => array(800 , 600),
                  'bann27' => array(900 , 612) );

list($px, $py) = $banners[$imagesize];

That block of code will replace lines 14 - 170 and you pull the $px and $py variables for each banner from from just one line of code:

list($px, $py) = $banners[$imagesize];

Link to comment
Share on other sites

The 500 page error sounds like a bug that was recently introduced in PHP 5.2.4. In their infinite wisdom, php.net decided to - "Changed error handler to send HTTP 500 instead of blank page on PHP errors."

 

That by itself is not really a problem, but unfortunately, the programmer that changed the code removed or bypassed the call to the output buffer flush routine, so if you have output buffering on in php.ini and there is a fatal parse or runtime error, you won't get any output on the page (any errors due to error reporting or content up to the point of a fatal runtime error to indicate at what point the error occurred), just the HTTP 500 page.

 

If the above is what you are seeing, either upgrade to php 5.2.5 or turn off output buffering in php.in/.htaccess.

Link to comment
Share on other sites

cool --- that made things better ---- am now handling empty results and erroring with:

results were found

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/memphisb/public_html/sig/search.php on line 244

 

 

i'm perhaps a bit worn out and just looking from too close a perspective... I appreciate the help --- my programming is rusty as I've not been doing a lot of code the past 4 years as I was too busy helping my brother with lou gherig's disease...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.