Jump to content

code stopped working


stmosaic

Recommended Posts

This is weird and I'm at my wits end trying to see what is wrong with my code. Need another set of eyes to double check me. 4 days ago this code worked. Today to my horror, it didn't. Can anyone see what is wrong with my code? PHP Designer shows NO syntax errors. I appreciate any help you can offer.

 

<?php

$DBASE="dbname";
$DBTABLE="table";
$DBASEUSER="UN";
$DBASEPASSWORD="PW";

//DB CONNECTION//
$dbcnx = @mysql_connect("localhost", "$DBASEUSER", "$DBASEPASSWORD");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! @mysql_select_db("$DBASE") ) {
echo( "<p>Unable to locate the " .
"database at this time.</p>" );
exit();
}

$SelectedState=$_REQUEST['SelectedState'];

//testing variable passing//
echo "$SelectedState";
///////This testing WORKS////////

///Doesn't seem to work beyond here////
if ($SelectedState == "ALL")
{
$result = mysql_query("SELECT * FROM $DBTABLE WHERE Approved='Y' ORDER BY State, City, Name ASC");
}else{
$result = mysql_query("SELECT * FROM $DBTABLE WHERE State='$SelectedState' AND Approved='Y' ORDER BY City, Name ASC");
}

if (!$result) 
{
echo("<p>Error performing query: " . mysql_error() . "</p>");
if(mysql_num_rows($result) == 0)
    { 
        echo("There are no members in $SelectedState."); 
    } 
exit();
}
//abreviated this section of variables to save space on forum//

while ( $row = mysql_fetch_array($result))
{
$IDENT=$row["ID"];
$NAME=$row['Name'];
$COMPANY=$row['Company'];
$ADDRESS=$row['Address'];
$ADDRESS1=$row['Address1'];
$CITY=$row['City'];
$STATE=$row['State'];
$ZIP=$row['Zip'];
$MEMBERTYPE=$row['MemberType'];
$MARKETCITY1=$row['MarketCity1'];
$MARKETCITY2=$row['MarketCity2'];
$MARKETCITY3=$row['MarketCity3'];
$MARKETCITY4=$row['MarketCity4'];
$WEBSITEURL=$row['WebsiteURL'];


//===DISPLAY ALL LISTINGS===//
echo("<table width=\"100%\" border=0><tr><td width=\"50%\" valign=\"top\"><font face=\"Arial, Helvetica, sans-serif\" size=2><b>$NAME</b></font></td><td>");

if ($COMPANY != ""){echo ("<font face=\"Arial, Helvetica, sans-serif\" size=2><b>$COMPANY</b></font>");}

echo ("</td></tr><tr><td width=\"50%\" valign=\"top\"><font face=\"Arial, Helvetica, sans-serif\" size=2>$ADDRESS<br>");

if ($ADDRESS1 != ""){echo ("$ADDRESS1<br>");}

echo ("$CITY, $STATE, $ZIP<br>$MEMBERTYPE $MEMBERSHIPTYPE");

    if (($AGENTSNUMBER != "") OR ($AGENTSNUMBER != 0)) 
	{echo (":  $AGENTSNUMBER Agents");}

echo ("<br>$MARKETCITY1");

if ($MARKETCITY2 != ""){
			  echo(", $MARKETCITY2");
			  } 
			  if ($MARKETCITY3 != ""){
			  echo(", $MARKETCITY3");
			  } 				  
			  if ($MARKETCITY4 != ""){
			  echo(", $MARKETCITY4");
			  } 
			  
echo ("</font></td>
      <td colspan=2 valign=\"top\"><font face=\"Arial, Helvetica, sans-serif\" size=2><br>$PHONE<br>
      Fax: $FAX<br>
      $EMAIL<br>
      $WEBSITEURL<br>
</font></td>
                </tr>
              </table><br>
");					  
}
mysql_close($dbcnx);
?>

Link to comment
https://forums.phpfreaks.com/topic/56764-code-stopped-working/
Share on other sites

Expected output is the data from the database. If the passed parameter is "ALL", then it is to show all entries in the DB. If a state is selected, for example, NC. Then only those listings for NC show up. The code is giving me nothing but a blank where the output should be.

 

I've tested the passing of the variable & that works.

Link to comment
https://forums.phpfreaks.com/topic/56764-code-stopped-working/#findComment-282120
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.