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
Share on other sites

that's interesting because the same thing is happening to me and my script...it was working fine but then it just died on me....i still don't have a solution though because i too posted a thread about posting comments yesterday

Link to comment
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
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.