Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRAZY WEBSITE PROBLEM>< DELETES ONLY LOCAL LISTINGS

Status
Not open for further replies.

jbbadaz

Technical User
Mar 18, 2006
5
0
0
US
I have a gagrage sale website. Pretty simple php coded site. Nothing to dramatic. I have 2 questions.
1. When anyone from my local community posts a lisitng on this site. They get deleted somehow. If you enter any other city on the post a sale page it works fine. But three local cities here will not work. I am sure it is something I have done to the page. I cannot find it. If you try to browse the listing it gets deleted. If i try to activate it through admin section, deleted. It will show an active listing in the counter,but as soon as you try to browse it gone, Deleted. Every other city works. Where would I start to look for this problem. I show no errors in the log files. Is this a mysql problemo or what? I have looked over the page. I can remember the changes I made just not exactly where I made them or how to reverse them. Please help.

2. I have sucessfully added a members section to the site as well as affiliate section I have tried repeatedly to add links to the main page to these new sections. I am unsure of how to make these changes to the index file. I have tried trial and error. Please bear in mind that I am teaching myself this stuff by reading tutorials and testing it. I would just like to know which direction I should go to add these links. I have noticed that I can add an image behind an image. This make me think of cascade sheets, which would be another new field of study for me. But I am willing. I am happy with just basic text links.
I have found I do not lack the common sense to llok at code and figure out what s going on and what is happening. I do however lack the correct terminology to make google find answers. Could someone please help me.
Thanks.
 
<?
include_once("conn.php");
include_once("include.php");
include_once("header.php");

//get the settings
$qset = "select * from garage_settings";
$rset = mysql_query($qset) or die(mysql_error());
$aset = mysql_fetch_array($rset);

if(isset($_POST[add_post]))
{
$NewData = explode("|", $_POST[StateProvince]);

$Country = $NewData[0];
$StateProvince = $NewData[1];


if(!empty($_POST[NewCityName]))
{
$MyNewCity = trim($_POST[NewCityName]);
}
else
{
$MyNewCity = trim($_POST[City]);
}

if($Country == 'Canada')
{
$qtotal = "update garage_total set canada = canada + 1";
$rtotal = mysql_query($qtotal) or die(mysql_error());

$qcheck = "select * from garage_cities where city like '%,$MyNewCity' ";
$rcheck = mysql_query($qcheck) or die(mysql_error);

if(mysql_num_rows($rcheck) == '0' )
{
$CityCheck="$StateProvince,$MyNewCity";
$qcheck2 = "insert into garage_cities set city = '$CityCheck' ";
$rcheck2 = mysql_query($qcheck2) or die(mysql_error());
}

$uZipCode = strtoupper($_POST[ZipCode]);

//postal code first symbol
$pt1 = substr($uZipCode, 0, 1);

//postal code second symbol
$pt2 = substr($uZipCode, 1, 2);

//postal code third symbol
$pt3 = substr($uZipCode, 2, 3);

//postal code fourth symbol "-"
$pt4 = substr($uZipCode, 3, 4);

//postal code fith symbol
$pt5 = substr($uZipCode, 4, 5);

//postal code sixth symbol
$pt6 = substr($uZipCode, 5, 6);

//postal code seventh symbol
$pt7 = substr($uZipCode, 6, 7);

if(strlen($_POST[ZipCode]) < '7' || !ereg('[A-Z]', $pt1) || !ereg('[0-9]', $pt2) || !ereg('[A-Z]', $pt3) || !ereg('[-]', $pt4) || !ereg('[0-9]', $pt5) || !ereg('[A-Z]', $pt6) || !ereg('[0-9]', $pt7) )
{
echo "<center>The correct format for Canadian Post Code is: <b>L2V-4P1</b> but you had submited <b>$_POST[ZipCode]</b><br>Go back and fix this problem.</center>";
exit();
}
}
elseif($Country == 'USA')
{
$qtotal = "update garage_total set usa = usa + 1";
$rtotal = mysql_query($qtotal) or die(mysql_error());

$qcheck = "select * from garage_cities_usa where city like '%,$MyNewCity' ";
$rcheck = mysql_query($qcheck) or die(mysql_error);

if(mysql_num_rows($rcheck) == '0' )
{
$CityCheck="$StateProvince,$MyNewCity";
$qcheck2 = "insert into garage_cities_usa set city = '$CityCheck' ";
$rcheck2 = mysql_query($qcheck2) or die(mysql_error());
}
}


//insert into database and send confirm
$NewStreetAddress = trim($_POST[StreetAddress]);
$NewCity = $MyNewCity;
$NewZip = trim($_POST[ZipCode]);
$NewZip = strtoupper($NewZip);
$NewSaleDate = mktime(0,0,0,$_POST[month], $_POST[day], $_POST[year]);

if($_POST[sth] == 'AM')
{
$NewStartTime = mktime($_POST[h1], $_POST[m1], 0, $_POST[month], $_POST[day], $_POST[year]);
}
elseif($_POST[sth] == 'PM')
{
$NewStartTime = mktime($_POST[h1] + 12, $_POST[m1], 0, $_POST[month], $_POST[day], $_POST[year]);
}


if($_POST[eth] == 'AM')
{
$NewEndTime = mktime($_POST[h2], $_POST[m2], 0, $_POST[month], $_POST[day], $_POST[year]);
}
elseif($_POST[eth] == 'PM')
{
$NewEndTime = mktime($_POST[h2] +12, $_POST[m2], 0, $_POST[month], $_POST[day], $_POST[year]);
}


$sm = $_FILES[ImageUP][name];

if(!empty($sm))
{
$im_size = $_FILES[ImageUP][size];

if(($im_size/1000) > $aset[MaxSize])
{
echo "<center>Your image must be less than 400 Kb in size.<br>Go back and select another one, please.</center>";
exit();
}

$pref = time();
$ImageName2 = "$pref$sm";

copy($_FILES[ImageUP][tmp_name], "./up_files/$ImageName2");

$NewPrice = number_format($_POST[UploadPrice], 2, ".", "");
}


if(!empty($_POST[Description]) && $_POST[DescPrice] > '0')
{
$NewPrice = number_format($_POST[DescPrice] + $NewPrice, 2, ".", "");
}

if(!empty($_POST[bh1]))
{
$NewBold = explode("|", $_POST[bh1]);

$NewPrice = number_format($NewBold[1] + $NewPrice, 2, ".", "");
}


$PostingDate = time();

$ac = crypt($_REQUEST['PHPSESSID']);

$qad = "insert into garage_ads set
Category = '$_POST[Category]',
EmailAddress = '$_POST[EmailAddress]',
StreetAddress = '$NewStreetAddress',
City = '$MyNewCity',
StateProvince = '$StateProvince',
Country = '$Country',
ZipCode = '$NewZip',
PhoneNumber = '$_POST[PhoneNumber]',
SaleDate = '$NewSaleDate',
StartTime = '$NewStartTime',
EndTime = '$NewEndTime',
RainShine = '$_POST[RainShine]',
Description = '$_POST[Description]',
BoldHighlight = '$NewBold[0]',
Image = '$ImageName2',
Price = '$NewPrice',
PostingDate = '$PostingDate',
ac = '$ac' ";
$raq = mysql_query($qad) or die(mysql_error());

$last = mysql_insert_id();


if($NewPrice > '0')
{
//go to pay

//get the payment details
$qpay = "select * from garage_settings";
$rpay = mysql_query($qpay) or die(mysql_error());
$apay = mysql_fetch_array($rpay);


echo "<br><center>To activate your $_POST[Category] sale ad, you should pay the price of $ $NewPrice<br><br>To do this, you can use:<br><br>";

if(!empty($apay[PayPal]))
{
//paypal code here
?>

<form action=" method="post">
<input type="hidden" name="business" value="<?=$apay[PayPal]?>">
<input type="hidden" name="item_name" value="Ad ID: <?=$last?>">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="amount" value="<?=$NewPrice?>">
<input type=hidden name=custom value="<?=$last?>">
<input type=hidden name=return value="[HTTP_HOST]?>/thankyou.php">
<input type=hidden name=notify_url value="[HTTP_HOST]?>/notify.php">
<input type="image" src=" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>

<?
echo "<br><br>";
}

if(!empty($apay[TWO_checkout]))
{
//2checkout.com code
$url="[TWO_checkout]&total=$NewPrice&cart_order_id=$last";
echo "<a href=\"$url\"><img src=\"my_images/2co_logo_small.gif\" border=0></a><br><br>";
}


echo "</center>";
}
else
{

//send an email to the user
$to = $_POST[EmailAddress];
$from = "FROM: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>";
$subject = "Your $_SERVER[HTTP_HOST] post";

$message = "Hello,\nthank you for your post at $_SERVER[HTTP_HOST]\nHere are your ad details:\n\n";
$message .= "Ad ID: $last\nCategory: $_POST[Category]\nContact email: $to\nStreet Address: $NewStreetAddress\nCity: $MyNewCity\nState/Province: $StateProvince\nZip/Postal Code: $_POST[ZipCode]\nCountry: $Country\nPhone Number: $_POST[PhoneNumber]\nSale Date: $_POST[month] - $_POST[day] - $_POST[year]\nStart time: $_POST[h1]:$_POST[m1]\nEnd time: $_POST[h2]:$_POST[m2]\nRane/Shine: $_POST[RainShine]\n";
$message .= "You did not select bold.\nYou did not select highlight.\nYou did not add a picture.\n";


//check the validation method
$qv = "select AdValidationType from garage_settings";
$rv = mysql_query($qv) or die(mysql_error());
$av = mysql_fetch_array($rv);

if($av[0] == 'email')
{
$url = "[HTTP_HOST]/a.php?ac=$ac";

$message .= "\n\nClick the link below, to activate your posting.\n$url\n\n";

$ShowAnswer = "<br><center><font size=2><b>An activation code was send to your email!</b></font></center>";
}
else
{
$ShowAnswer = "<center><br><font size=2><b>You will receive an email after the ad is approved by admin.</b></font></center>";
}

mail($to, $subject, $message, $from);

echo $ShowAnswer;
}


}
else
{
?>

<form method=post name=p1 enctype="multipart/form-data" onsubmit="return CheckPost();">

<table align=center width=755 border=0>
<caption align=left><font size=2><b>Post a new ad at "<?=$_GET[Category]?> Sale" category</b></font></caption>

<tr>
<td colspan=4 align=center>
<hr size=2 color="#000000" width="100%">
</td>
</tr>

<tr>
<td>Contact Email:</td>
<td><input type=text name=EmailAddress value="<?=$_POST[EmailAddress]?>"></td>

<td>Street Address:</td>
<td><input type=text name=StreetAddress value="<?=$_POST[StreetAddress]?>" size=45></td>
</tr>

<tr>
<td>Select a city:</td>
<td>
<select name=City>
<option value=""></option>
<option value="">--------------------</option>
<option value="">Canadian Cities:</option>
<option value="">--------------------</option>
<?
$qsp = "select * from garage_cities order by city";
$rsp = mysql_query($qsp) or die(mysql_error());
while($asp = mysql_fetch_array($rsp))
{
$trim1 = trim($asp[city]);

$NewStr = explode(",", $trim1);

$trim2 = trim($NewStr[1]);

echo "<option value=\"$trim2\">$trim1</option>\n";
}
?>

<option value="">--------------------</option>
<option value="">USA Cities</option>
<option value="">--------------------</option>

<?
$qsp = "select * from garage_cities_usa order by city";
$rsp = mysql_query($qsp) or die(mysql_error());
while($asp = mysql_fetch_array($rsp))
{
$trim1 = trim($asp[city]);

$NewStr = explode(",", $trim1);

$trim2 = trim($NewStr[1]);

echo "<option value=\"$trim2\">$trim1</option>\n";
}
?>
</select>

</td>

<td>Phone number:</td>
<td><input type=text name=PhoneNumber value="<?=$_POST[PhoneNumber]?>"></td>
</tr>

<tr>
<td colspan=4>
Or enter a new city, if your's do not exists in the list: <input type=text name=NewCityName>

<tr>
<td colspan=4>
<table align=center width="100%" cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=left width="40%">
State/Province:
<select name=StateProvince>
<option value="">select</option>
<option value="">----------</option>
<option value="Canada|AB">Alberta</option>
<option value="Canada|BC">British Columbia</option>
<option value="Canada|MB">Manitoba</option>
<option value="Canada|NB">New Brunswick</option>
<option value="Canada|NF">Newfoundland and Labrador</option>
<option value="Canada|NT">Northwest Territories</option>
<option value="Canada|NS">Nova Scotia</option>
<option value="Canada|NU">Nunavut</option>
<option value="Canada|ON">Ontario</option>
<option value="Canada|PE">Prince Edward Island</option>
<option value="Canada|QC">Quebec</option>
<option value="Canada|SK">Saskatchewan</option>
<option value="Canada|YT">Yukon</option>
<option value="">----------</option>
<OPTION VALUE="USA|AL">Alabama</OPTION>
<OPTION VALUE="USA|AK">Alaska</OPTION>
<OPTION VALUE="USA|AZ">Arizona</OPTION>
<OPTION VALUE="USA|AR">Arkansas</OPTION>
<OPTION VALUE="USA|CA">California</OPTION>
<OPTION VALUE="USA|CO">Colorado</OPTION>
<OPTION VALUE="USA|CT">Connecticut</OPTION>
<OPTION VALUE="USA|DE">Delaware</OPTION>
<OPTION VALUE="USA|DC">District of Columbia</OPTION>
<OPTION VALUE="USA|FL">Florida</OPTION>
<OPTION VALUE="USA|GA">Georgia</OPTION>
<OPTION VALUE="USA|HI">Hawaii</OPTION>
<OPTION VALUE="USA|ID">Idaho</OPTION>
<OPTION VALUE="USA|IL">Illinois</OPTION>
<OPTION VALUE="USA|IN">Indiana</OPTION>
<OPTION VALUE="USA|IA">Iowa</OPTION>
<OPTION VALUE="USA|KS">Kansas</OPTION>
<OPTION VALUE="USA|KY">Kentucky</OPTION>
<OPTION VALUE="USA|LA">Louisiana</OPTION>
<OPTION VALUE="USA|ME">Maine</OPTION>
<OPTION VALUE="USA|MD">Maryland</OPTION>
<OPTION VALUE="USA|MA">Massachusetts</OPTION>
<OPTION VALUE="USA|MI">Michigan</OPTION>
<OPTION VALUE="USA|MN">Minnesota</OPTION>
<OPTION VALUE="USA|MS">Mississippi</OPTION>
<OPTION VALUE="USA|MO">Missouri</OPTION>
<OPTION VALUE="USA|MT">Montana</OPTION>
<OPTION VALUE="USA|NE">Nebraska</OPTION>
<OPTION VALUE="USA|NV">Nevada</OPTION>
<OPTION VALUE="USA|NH">New Hampshire</OPTION>
<OPTION VALUE="USA|NJ">New Jersey</OPTION>
<OPTION VALUE="USA|NM">New Mexico</OPTION>
<OPTION VALUE="USA|NY">New York</OPTION>
<OPTION VALUE="USA|NC">North Carolina</OPTION>
<OPTION VALUE="USA|ND">North Dakota</OPTION>
<OPTION VALUE="USA|OH">Ohio</OPTION>
<OPTION VALUE="USA|OK">Oklahoma</OPTION>
<OPTION VALUE="USA|OR">Oregon</OPTION>
<OPTION VALUE="USA|PA">Pennsylvania</OPTION>
<OPTION VALUE="USA|RI">Rhode Island</OPTION>
<OPTION VALUE="USA|SC">South Carolina</OPTION>
<OPTION VALUE="USA|SD">South Dakota</OPTION>
<OPTION VALUE="USA|TN">Tennessee</OPTION>
<OPTION VALUE="USA|TX">Texas</OPTION>
<OPTION VALUE="USA|UT">Utah</OPTION>
<OPTION VALUE="USA|VT">Vermont</OPTION>
<OPTION VALUE="USA|VA">Virginia</OPTION>
<OPTION VALUE="USA|WA">Washington</OPTION>
<OPTION VALUE="USA|WV">West Virginia</OPTION>
<OPTION VALUE="USA|WI">Wisconsin</OPTION>
<OPTION VALUE="USA|WY">Wyoming</OPTION>
</select>
</td>

<td align=left width=32% style="padding-left:20">
Zip Code: <input type=text name=ZipCode value="<?=$_POST[ZipCode]?>" maxlength=7>
</td>

<td>&nbsp;</td>

</tr>
</table>
</td>
</tr>

<tr>
<td colspan=4 align=center>
<hr size=2 color="#000000" width="100%">
</td>
</tr>

</table>


<table align=center width=755 border=0>
<tr>
<td>Sale date:</td>
<td>

<select name=month>
<?

$my_months = array(date(n), $_POST[month]);

for($m = '1'; $m <= '12'; $m++)
{
$MonthWord = date('F', mktime(0,0,0,$m,date(d), date(Y)));

if(in_array($m, $my_months))
{
echo "<option value=$m selected>$MonthWord</option>\n\t";
}
else
{
echo "<option value=$m>$MonthWord</option>\n\t";
}
}
?>
</select>

&nbsp;

<select name=day>
<?
for($d = '1'; $d <= '31'; $d++)
{
if($d == date(j) || $d == $_POST[day])
{
echo "<option value=$d selected>$d</option>";
}
else
{
echo "<option value=$d>$d</option>";
}
}
?>
</select>

&nbsp;

<select name=year>
<?
for($y = date(Y); $y <= (date(Y) + 1); $y++)
{
if($y == date(Y) || $y == $_POST[year])
{
echo "<option value=$y selected>$y</option>\n";
}
else
{
echo "<option value=$y>$y</option>\n";
}
}
?>
</select>

</td>

<td>Start time:</td>
<td>
<select name=h1>
<?
for($h_st = '1'; $h_st <= '12'; $h_st++)
{
if($h_st == '9' || $h_st == $_POST[h1])
{
echo "<option value=$h_st selected>$h_st</option>\n";
}
else
{
echo "<option value=$h_st>$h_st</option>\n";
}
}
?>
</select>

:

<select name=m1>
<option value="00" selected>00</option>
<option value="30">30</option>
</select>

<select name=sth>
<option value=AM selected>AM</option>
<option value=PM>PM</option>
</select>
</td>


<td>End time:</td>
<td>
<select name=h2>
<?
for($h_end = '1'; $h_end <= '12'; $h_end++)
{
if($h_end == '3' || $h_end == $_POST[h2])
{
echo "<option value=$h_end selected>$h_end</option>\n";
}
else
{
echo "<option value=$h_end>$h_end</option>\n";
}
}
?>
</select>

:

<select name=m2>
<option value="00" selected>00</option>
<option value="30">30</option>
</select>

<select name=eth>
<option value=AM>AM</option>
<option value=PM selected>PM</option>
</select>

</td>


</tr>

<tr>
<td colspan=6>
Rain/Shine: <input type=radio name=RainShine value=yes checked>yes &nbsp;&nbsp;&nbsp; <input type=radio name=RainShine value=no>no
</td>
</tr>

<tr>
<td colspan=6 align=center>
<hr size=2 color="#000000" width="100%">
</td>
</tr>

<tr>
<td colspan=2 align=right valign=top>
<b>Garage Sale Description:</b><br>

<?
//get the prices
$qp = "select * from garage_settings";
$rp = mysql_query($qp) or die(mysql_error());
$ap = mysql_fetch_array($rp);

if($ap[DescPrice] > '0')
{
echo "<font size=1>If you add a sale description, it will cost you $";
echo number_format($ap[DescPrice], 2, ".", "");

}

?>
<br><b>Important!</b> There is a 50 words maximum!
</font>
</td>

<td colspan=4><textarea rows=6 cols=30 name=Description maxlength=150><?=$_POST[Description]?></textarea><br>
<input type=radio name=bh1 value="" <? if($_POST[bh1] == "") { echo "selected"; } ?>>Plain text<br>
<input type=radio name=bh1 value="1|<?=$ap[BoldPrice]?>" <? if($_POST[bh1] == "1|<?=$ap[BoldPrice]?>") { echo "selected"; } ?>> Add $ <?=number_format($ap[BoldPrice], 2, ".", "");?> for <b>bold</b> description.<br>
<input type=radio name=bh1 value="2|<?=$ap[BH_price]?>" <? if($_POST[bh1] == "2|<?=$ap[BH_price]") { echo "selected"; } ?>> Add $ <?=number_format($ap[BH_price], 2, ".", "");?> for <span style="background-color:yellow"><b>bold and hightlited description.</b></span><br>

</td>
</tr>

<tr>
<td colspan=6 align=center>
<hr size=2 color="#000000" width="100%">
</td>
</tr>

<tr>
<td colspan=6>
<b>Upload Picture:</b> <input type=file name=ImageUP size=30"> (max file size: 400 Kb) <br>
If you upload an image, it will cost you $ <?=number_format($ap[UploadPrice], 2, ".", "");?>
</td>
</tr>

<tr>
<td colspan=6 align=center>
<hr size=2 color="#000000" width="100%">
</td>
</tr>

<tr>
<td colspan=6 align=center>
<input type=hidden name=UploadPrice value="<?=$ap[UploadPrice]?>">
<input type=hidden name=DescPrice value="<?=$ap[DescPrice]?>">
<input type=hidden name=Category value="<?=$_GET[Category]?>">
<input type=submit name="add_post" value="Post my ad">
</td>
</tr>


</table>

</form>

<?
}

include_once("bottom.php");
?>
 
do you live in ontario?

i think your problem (in part) is the way you construct your selects. take, for example, the following output from your site (in the city select statement)

Code:
<option value="Ontario">ON,Ontario, Fenwick</option>
<option value="Ontario">ON,Ontario, Fonthill</option>
<option value="Ontario">ON,Ontario, Vineland</option>

your server will just not know which is which as the values are all the same. there may well be other instances that are similar (i gave up after finding the first instance of what i was looking for).
 
The site only deletes the listings on the USA side of the page. It seems to be narrowed down to three zip codes.
all other areas function properly.
Could you elaborate more, or in basic terms. I woul dlike to solve this problem.
 
it's not post codes. you are not populating your list boxes with unique values. it's a classic garbage-in, garbage-out problem.

i doubt whether the records are deleted either - i suspect that they are being written but with unexpected data.

to solve it - use unique values.
 
that is the simple change in my php admin to the table for the cities. Yes
 
i would use add a primary index column to your cities table and then use this value in the list box.

which cities are those with which you have problems?
 
I got it figured out. The hosting admin had patched a script that deletes the lisitngs automatically. I commented it out and works now. Just does not delete thei listings automatically. I will post the script in a while.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top